From 0203dfc40768a70922b4a6074d8de5521f2b63b2 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 12 Oct 2020 16:15:46 +0530 Subject: [PATCH 01/17] added hook --- scripts/pre-commit.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 scripts/pre-commit.sh diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh new file mode 100644 index 00000000000..f8e22b86ffc --- /dev/null +++ b/scripts/pre-commit.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +echo "Checking code formatting" + +ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt + +status=$? + +if [ "$status" = 0 ] ; then + echo "Lint completed successfully" + exit 0 +else + echo 1>&2 "Ktlint issue found" + exit 1 +fi From e590ed5ac8536c6d540ab7cd22144114e187f64c Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 13 Oct 2020 10:14:03 +0530 Subject: [PATCH 02/17] introduce ktlint pre-commit-hook --- scripts/pre-commit | 20 ++++++++++++++++ scripts/setup.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100755 scripts/pre-commit create mode 100644 scripts/setup.py diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100755 index 00000000000..d089c3f98ec --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,20 @@ +#!/bin/sh + +echo "********************************" +echo "Checking code formatting" +echo "********************************" + +ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt + +status=$? + +if [ "$status" = 0 ] ; then + echo "Lint completed successfully." + exit 0 +else + echo "********************************" + echo "Ktlint issue found." + echo "Please fix the above issues." + echo "********************************" + exit 1 +fi diff --git a/scripts/setup.py b/scripts/setup.py new file mode 100644 index 00000000000..742b432408a --- /dev/null +++ b/scripts/setup.py @@ -0,0 +1,57 @@ +import shutil +import platform +import subprocess +import os + +OS_NAME = platform.system() + +# INSTRUCTIONS: +# This script will move the pre-commit script from scripts folder to .git/hooks folder +# to activate the checks prior to any commits. +# +# Run the script from the oppia-android root folder: +# +# python scripts/setup.py +# + +def install_hook(): + """Installs the pre_commit_hook script and makes it executable. + It ensures that oppia-android/ is the root folder. + """ + oppia_android_dir = os.getcwd() + hooks_dir = os.path.join(oppia_android_dir, '.git', 'hooks') + pre_commit_file = os.path.join(hooks_dir, 'pre-commit') + chmod_cmd = ['chmod', '+x', pre_commit_file] + file_exists = os.path.exists(pre_commit_file) + if file_exists: + print('Pre-commit hook already exists') + else: + shutil.copy('scripts/pre-commit', '.git/hooks/') + print('Copied file to .git/hooks directory') + + print('Making pre-commit hook file executable ...') + if not is_windows_os(): + _, err_chmod_cmd = start_subprocess_for_result(chmod_cmd) + + if not err_chmod_cmd: + print('Pre-commit hook file is now executable!') + else: + raise ValueError(err_chmod_cmd) + +def is_windows_os(): + """Check if the running system is Windows.""" + return OS_NAME == 'Windows' + +def start_subprocess_for_result(cmd): + """Starts subprocess and returns (stdout, stderr).""" + task = subprocess.Popen( + cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = task.communicate() + return out, err + +def main(args=None): + """All the initial setup requirements functions will call from here.""" + install_hook() + +if __name__ == '__main__': + main() From 5d979a6a86decd9f4c8907f369709b1f6a63831e Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 13 Oct 2020 10:22:04 +0530 Subject: [PATCH 03/17] remove bad file --- scripts/pre-commit.sh | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 scripts/pre-commit.sh diff --git a/scripts/pre-commit.sh b/scripts/pre-commit.sh deleted file mode 100644 index f8e22b86ffc..00000000000 --- a/scripts/pre-commit.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -echo "Checking code formatting" - -ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt - -status=$? - -if [ "$status" = 0 ] ; then - echo "Lint completed successfully" - exit 0 -else - echo 1>&2 "Ktlint issue found" - exit 1 -fi From 50a85bf61273e37caad1e42b5c8ad12dabba1365 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 19 Oct 2020 15:51:41 +0530 Subject: [PATCH 04/17] replace python script with bash, add auto format --- scripts/pre-commit | 2 +- scripts/setup.py | 57 ---------------------------------------------- scripts/setup.sh | 14 ++++++++++++ 3 files changed, 15 insertions(+), 58 deletions(-) delete mode 100644 scripts/setup.py create mode 100644 scripts/setup.sh diff --git a/scripts/pre-commit b/scripts/pre-commit index d089c3f98ec..747de2b7c29 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -4,7 +4,7 @@ echo "********************************" echo "Checking code formatting" echo "********************************" -ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt +ktlint -F --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt status=$? diff --git a/scripts/setup.py b/scripts/setup.py deleted file mode 100644 index 742b432408a..00000000000 --- a/scripts/setup.py +++ /dev/null @@ -1,57 +0,0 @@ -import shutil -import platform -import subprocess -import os - -OS_NAME = platform.system() - -# INSTRUCTIONS: -# This script will move the pre-commit script from scripts folder to .git/hooks folder -# to activate the checks prior to any commits. -# -# Run the script from the oppia-android root folder: -# -# python scripts/setup.py -# - -def install_hook(): - """Installs the pre_commit_hook script and makes it executable. - It ensures that oppia-android/ is the root folder. - """ - oppia_android_dir = os.getcwd() - hooks_dir = os.path.join(oppia_android_dir, '.git', 'hooks') - pre_commit_file = os.path.join(hooks_dir, 'pre-commit') - chmod_cmd = ['chmod', '+x', pre_commit_file] - file_exists = os.path.exists(pre_commit_file) - if file_exists: - print('Pre-commit hook already exists') - else: - shutil.copy('scripts/pre-commit', '.git/hooks/') - print('Copied file to .git/hooks directory') - - print('Making pre-commit hook file executable ...') - if not is_windows_os(): - _, err_chmod_cmd = start_subprocess_for_result(chmod_cmd) - - if not err_chmod_cmd: - print('Pre-commit hook file is now executable!') - else: - raise ValueError(err_chmod_cmd) - -def is_windows_os(): - """Check if the running system is Windows.""" - return OS_NAME == 'Windows' - -def start_subprocess_for_result(cmd): - """Starts subprocess and returns (stdout, stderr).""" - task = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = task.communicate() - return out, err - -def main(args=None): - """All the initial setup requirements functions will call from here.""" - install_hook() - -if __name__ == '__main__': - main() diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100644 index 00000000000..74c78c99efc --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# INSTRUCTIONS: +# This script will move the pre-commit hook from script folder to +# the .git/hooks folder +# +# Run the script from the oppia-android root folder: +# +# bash scripts/setup.sh +# +# NOTE: this script should be run once after the initial codebase setup + +# Move file from script folder to .git/hooks folder +mv scripts/pre-commit .git/hooks/ From f7402f1a2d16766a86197cfcadea718d35ff7c49 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Wed, 21 Oct 2020 14:44:48 +0530 Subject: [PATCH 05/17] added messge to fix issues --- scripts/pre-commit | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/pre-commit b/scripts/pre-commit index 747de2b7c29..7b8256be36c 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -14,7 +14,10 @@ if [ "$status" = 0 ] ; then else echo "********************************" echo "Ktlint issue found." - echo "Please fix the above issues." + echo "Please fix the above issues. You could also use ktlint -F --android path/to/file.kt + command to fix most of the issues." + echo "Please note, there might be possibility where the above command will not fix the issue, + you have to fix it yourself." echo "********************************" exit 1 fi From 57d81447e9027ffa6cbbabaaaeced4d9e0ee0b82 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Sun, 25 Oct 2020 14:02:04 +0530 Subject: [PATCH 06/17] single pre-commit to run diff hooks --- scripts/ktlint-pre-commit | 23 +++++++++++++++++++++++ scripts/pre-commit | 33 ++++++++++++--------------------- 2 files changed, 35 insertions(+), 21 deletions(-) create mode 100755 scripts/ktlint-pre-commit diff --git a/scripts/ktlint-pre-commit b/scripts/ktlint-pre-commit new file mode 100755 index 00000000000..7b8256be36c --- /dev/null +++ b/scripts/ktlint-pre-commit @@ -0,0 +1,23 @@ +#!/bin/sh + +echo "********************************" +echo "Checking code formatting" +echo "********************************" + +ktlint -F --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt + +status=$? + +if [ "$status" = 0 ] ; then + echo "Lint completed successfully." + exit 0 +else + echo "********************************" + echo "Ktlint issue found." + echo "Please fix the above issues. You could also use ktlint -F --android path/to/file.kt + command to fix most of the issues." + echo "Please note, there might be possibility where the above command will not fix the issue, + you have to fix it yourself." + echo "********************************" + exit 1 +fi diff --git a/scripts/pre-commit b/scripts/pre-commit index 7b8256be36c..f36aa67cd61 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -1,23 +1,14 @@ #!/bin/sh -echo "********************************" -echo "Checking code formatting" -echo "********************************" - -ktlint -F --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt - -status=$? - -if [ "$status" = 0 ] ; then - echo "Lint completed successfully." - exit 0 -else - echo "********************************" - echo "Ktlint issue found." - echo "Please fix the above issues. You could also use ktlint -F --android path/to/file.kt - command to fix most of the issues." - echo "Please note, there might be possibility where the above command will not fix the issue, - you have to fix it yourself." - echo "********************************" - exit 1 -fi +# INSTRUCTIONS: +# This script will run the pre-commit checks in the given order +# Ktlint +# + +# this will run the ktlint check script +bash ktlint-pre-commit + +# TODO() Add Bazel Linter to the project #1736 +# TODO() Add Java Linter to the project #1735 +# TODO() Add an XML Linter to the project #970 +# TODO() Add Buf linter From 901ad54784bcf8cc073a76e3ad4ee9c1d186b33a Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 27 Oct 2020 11:08:21 +0530 Subject: [PATCH 07/17] nit change --- .github/workflows/main.yml | 2 +- scripts/{ktlint-pre-commit => kotlin-lint-check} | 6 +++--- scripts/pre-commit | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) rename scripts/{ktlint-pre-commit => kotlin-lint-check} (64%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0757074460d..913f38dc253 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: chmod a+x buf - name: Kotlin lint check - run: ./ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt && echo "Lint completed successfully" + run: bash ./scripts/kotlin-pre-commit - name: Protobuf lint check run: ./buf check lint --input=model/src/main/proto --input-config buf.yaml && echo "Protobuf lint check completed successfully" diff --git a/scripts/ktlint-pre-commit b/scripts/kotlin-lint-check similarity index 64% rename from scripts/ktlint-pre-commit rename to scripts/kotlin-lint-check index 7b8256be36c..910b2824b50 100755 --- a/scripts/ktlint-pre-commit +++ b/scripts/kotlin-lint-check @@ -4,7 +4,7 @@ echo "********************************" echo "Checking code formatting" echo "********************************" -ktlint -F --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt +ktlint --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt status=$? @@ -16,8 +16,8 @@ else echo "Ktlint issue found." echo "Please fix the above issues. You could also use ktlint -F --android path/to/file.kt command to fix most of the issues." - echo "Please note, there might be possibility where the above command will not fix the issue, - you have to fix it yourself." + echo "Please note, there might be a possibility where the above commend will not fix the issue. + In that case, you will have to fix it yourself." echo "********************************" exit 1 fi diff --git a/scripts/pre-commit b/scripts/pre-commit index f36aa67cd61..d52276026f2 100755 --- a/scripts/pre-commit +++ b/scripts/pre-commit @@ -6,7 +6,7 @@ # # this will run the ktlint check script -bash ktlint-pre-commit +bash kotlin-lint-check # TODO() Add Bazel Linter to the project #1736 # TODO() Add Java Linter to the project #1735 From c2c7d5b6c437d2fc3ddd6805c5a8f13508e03d6a Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 27 Oct 2020 11:12:04 +0530 Subject: [PATCH 08/17] revert small change --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 913f38dc253..0757074460d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: chmod a+x buf - name: Kotlin lint check - run: bash ./scripts/kotlin-pre-commit + run: ./ktlint --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt && echo "Lint completed successfully" - name: Protobuf lint check run: ./buf check lint --input=model/src/main/proto --input-config buf.yaml && echo "Protobuf lint check completed successfully" From 4f24faab1a749fcb69dda4998ba12f0f6fb02092 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Thu, 29 Oct 2020 08:47:08 +0530 Subject: [PATCH 09/17] update to pre-push --- scripts/{pre-commit => pre-push} | 2 +- scripts/setup.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename scripts/{pre-commit => pre-push} (80%) diff --git a/scripts/pre-commit b/scripts/pre-push similarity index 80% rename from scripts/pre-commit rename to scripts/pre-push index d52276026f2..db40d0b136e 100755 --- a/scripts/pre-commit +++ b/scripts/pre-push @@ -1,7 +1,7 @@ #!/bin/sh # INSTRUCTIONS: -# This script will run the pre-commit checks in the given order +# This script will run the pre-push checks in the given order # Ktlint # diff --git a/scripts/setup.sh b/scripts/setup.sh index 74c78c99efc..8dff4b62b23 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # INSTRUCTIONS: -# This script will move the pre-commit hook from script folder to +# This script will move the pre-push hook from script folder to # the .git/hooks folder # # Run the script from the oppia-android root folder: @@ -11,4 +11,4 @@ # NOTE: this script should be run once after the initial codebase setup # Move file from script folder to .git/hooks folder -mv scripts/pre-commit .git/hooks/ +mv scripts/pre-push .git/hooks/ From bb0abd477311b680b3eb6cbcb6729f4653626adf Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 9 Nov 2020 14:17:28 +0530 Subject: [PATCH 10/17] nit changes --- .../{kotlin-lint-check => kotlin-lint-check.sh} | 7 ++++--- scripts/pre-push | 14 ++++++-------- scripts/setup.sh | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) rename scripts/{kotlin-lint-check => kotlin-lint-check.sh} (69%) diff --git a/scripts/kotlin-lint-check b/scripts/kotlin-lint-check.sh similarity index 69% rename from scripts/kotlin-lint-check rename to scripts/kotlin-lint-check.sh index 910b2824b50..6083de74802 100755 --- a/scripts/kotlin-lint-check +++ b/scripts/kotlin-lint-check.sh @@ -14,9 +14,10 @@ if [ "$status" = 0 ] ; then else echo "********************************" echo "Ktlint issue found." - echo "Please fix the above issues. You could also use ktlint -F --android path/to/file.kt - command to fix most of the issues." - echo "Please note, there might be a possibility where the above commend will not fix the issue. + echo "Please fix the above issues. + You can also use the ktlint -F --android domain/src/**/*.kt utility/src/**/*.kt data/src/**/*.kt app/src/**/*.kt testing/src/**/*.kt + command to fix the most common issues." + echo "Please note, there might be a possibility where the above command will not fix the issue. In that case, you will have to fix it yourself." echo "********************************" exit 1 diff --git a/scripts/pre-push b/scripts/pre-push index db40d0b136e..c4398b9d213 100755 --- a/scripts/pre-push +++ b/scripts/pre-push @@ -1,14 +1,12 @@ #!/bin/sh -# INSTRUCTIONS: # This script will run the pre-push checks in the given order -# Ktlint -# +# - ktlint +# - (others in the future) -# this will run the ktlint check script bash kotlin-lint-check -# TODO() Add Bazel Linter to the project #1736 -# TODO() Add Java Linter to the project #1735 -# TODO() Add an XML Linter to the project #970 -# TODO() Add Buf linter +# TODO(#1736): Add Bazel Linter to the project +# TODO(#1735): Add Java Linter to the project +# TODO(#970): Add XML Linter to the project +# TODO(#2097): Add Buf Linter to the project diff --git a/scripts/setup.sh b/scripts/setup.sh index 8dff4b62b23..d3254e7ad7c 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/sh # INSTRUCTIONS: # This script will move the pre-push hook from script folder to From 8a3965e617d20dc87354c152579efb7f69e1ddae Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Mon, 9 Nov 2020 14:29:07 +0530 Subject: [PATCH 11/17] fixed reference --- scripts/pre-push | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pre-push b/scripts/pre-push index c4398b9d213..bffab520a25 100755 --- a/scripts/pre-push +++ b/scripts/pre-push @@ -4,7 +4,7 @@ # - ktlint # - (others in the future) -bash kotlin-lint-check +bash scripts/kotlin-lint-check.sh # TODO(#1736): Add Bazel Linter to the project # TODO(#1735): Add Java Linter to the project From 2266a7f1b8412999106cacaea498b5d517daef62 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 1 Dec 2020 11:33:41 +0530 Subject: [PATCH 12/17] checking pre-push exec --- .idea/gradle.xml | 3 ++- app/src/main/java/org/oppia/android/app/home/HomeActivity.kt | 2 +- scripts/{pre-push => pre-push.sh} | 0 scripts/setup.sh | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) rename scripts/{pre-push => pre-push.sh} (100%) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6aa35f75034..6466b7bedb7 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -20,7 +20,8 @@ - + \ No newline at end of file diff --git a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt index 18cd11517f0..0702a6bef64 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt @@ -1,5 +1,6 @@ package org.oppia.android.app.home +import javax.inject.Inject import android.content.Context import android.content.Intent import android.os.Bundle @@ -9,7 +10,6 @@ import org.oppia.android.app.drawer.ExitProfileDialogFragment import org.oppia.android.app.drawer.KEY_NAVIGATION_PROFILE_ID import org.oppia.android.app.drawer.TAG_SWITCH_PROFILE_DIALOG import org.oppia.android.app.topic.TopicActivity -import javax.inject.Inject /** The central activity for all users entering the app. */ class HomeActivity : InjectableAppCompatActivity(), RouteToTopicListener { diff --git a/scripts/pre-push b/scripts/pre-push.sh similarity index 100% rename from scripts/pre-push rename to scripts/pre-push.sh diff --git a/scripts/setup.sh b/scripts/setup.sh index d3254e7ad7c..9b9105d69fb 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -11,4 +11,4 @@ # NOTE: this script should be run once after the initial codebase setup # Move file from script folder to .git/hooks folder -mv scripts/pre-push .git/hooks/ +cp scripts/pre-push.sh .git/hooks/ From 6b3feaeda9989ddcbf5277164b0991fe699065e9 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Tue, 1 Dec 2020 11:48:37 +0530 Subject: [PATCH 13/17] making pre-push exec --- app/src/main/java/org/oppia/android/app/home/HomeActivity.kt | 2 +- scripts/setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt index 0702a6bef64..18cd11517f0 100644 --- a/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt +++ b/app/src/main/java/org/oppia/android/app/home/HomeActivity.kt @@ -1,6 +1,5 @@ package org.oppia.android.app.home -import javax.inject.Inject import android.content.Context import android.content.Intent import android.os.Bundle @@ -10,6 +9,7 @@ import org.oppia.android.app.drawer.ExitProfileDialogFragment import org.oppia.android.app.drawer.KEY_NAVIGATION_PROFILE_ID import org.oppia.android.app.drawer.TAG_SWITCH_PROFILE_DIALOG import org.oppia.android.app.topic.TopicActivity +import javax.inject.Inject /** The central activity for all users entering the app. */ class HomeActivity : InjectableAppCompatActivity(), RouteToTopicListener { diff --git a/scripts/setup.sh b/scripts/setup.sh index 9b9105d69fb..a18e365dbc4 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -11,4 +11,4 @@ # NOTE: this script should be run once after the initial codebase setup # Move file from script folder to .git/hooks folder -cp scripts/pre-push.sh .git/hooks/ +cp scripts/pre-push.sh .git/hooks/pre-push From f6015f65dcfe5867ebda8a66dd1075d215a14573 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Thu, 10 Dec 2020 15:37:05 +0530 Subject: [PATCH 14/17] remove unnecessary change --- .idea/gradle.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 6466b7bedb7..6aa35f75034 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -20,8 +20,7 @@ - \ No newline at end of file + From e587117e1a33d4939897af4a2849538602ec9446 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Fri, 18 Dec 2020 15:29:19 +0530 Subject: [PATCH 15/17] setting up ktlint and use it --- scripts/kotlin-lint-check.sh | 2 +- scripts/setup.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/kotlin-lint-check.sh b/scripts/kotlin-lint-check.sh index 6083de74802..e9eea0aeb5b 100755 --- a/scripts/kotlin-lint-check.sh +++ b/scripts/kotlin-lint-check.sh @@ -4,7 +4,7 @@ echo "********************************" echo "Checking code formatting" echo "********************************" -ktlint --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt +bash ../oppia-android-tools/ktlint --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt status=$? diff --git a/scripts/setup.sh b/scripts/setup.sh index a18e365dbc4..a7be055e0dd 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -10,5 +10,15 @@ # # NOTE: this script should be run once after the initial codebase setup +# Download ktlint +KTLINT="0.37.0" +echo Using Ktlint $KTLINT +cd .. +mkdir -p oppia-android-tools +cd oppia-android-tools +curl -sSL https://github.com/pinterest/ktlint/releases/download/$KTLINT/ktlint +chmod a+x ktlint +echo Ktlint file downloaded + # Move file from script folder to .git/hooks folder cp scripts/pre-push.sh .git/hooks/pre-push From 58d1a773946d3ab498ac7943b3e9c46e1bb4789f Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Fri, 18 Dec 2020 16:01:50 +0530 Subject: [PATCH 16/17] nit fix --- scripts/setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/setup.sh b/scripts/setup.sh index a7be055e0dd..e1e475e9864 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -10,6 +10,9 @@ # # NOTE: this script should be run once after the initial codebase setup +# Move file from script folder to .git/hooks folder +cp scripts/pre-push.sh .git/hooks/pre-push + # Download ktlint KTLINT="0.37.0" echo Using Ktlint $KTLINT @@ -19,6 +22,3 @@ cd oppia-android-tools curl -sSL https://github.com/pinterest/ktlint/releases/download/$KTLINT/ktlint chmod a+x ktlint echo Ktlint file downloaded - -# Move file from script folder to .git/hooks folder -cp scripts/pre-push.sh .git/hooks/pre-push From f2f9bcfa8d59e8aa82f0b9a75d08731031485af7 Mon Sep 17 00:00:00 2001 From: anandwana001 Date: Thu, 31 Dec 2020 16:00:04 +0530 Subject: [PATCH 17/17] using java jar --- scripts/kotlin-lint-check.sh | 2 +- scripts/setup.sh | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/kotlin-lint-check.sh b/scripts/kotlin-lint-check.sh index e9eea0aeb5b..149afa0b97f 100755 --- a/scripts/kotlin-lint-check.sh +++ b/scripts/kotlin-lint-check.sh @@ -4,7 +4,7 @@ echo "********************************" echo "Checking code formatting" echo "********************************" -bash ../oppia-android-tools/ktlint --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt +java -jar ../oppia-android-tools/ktlint --android app/src/**/*.kt data/src/**/*.kt domain/src/**/*.kt testing/src/**/*.kt utility/src/**/*.kt status=$? diff --git a/scripts/setup.sh b/scripts/setup.sh index e1e475e9864..c0dd4d0dfc2 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -14,11 +14,10 @@ cp scripts/pre-push.sh .git/hooks/pre-push # Download ktlint -KTLINT="0.37.0" +KTLINT="0.37.1" echo Using Ktlint $KTLINT -cd .. -mkdir -p oppia-android-tools -cd oppia-android-tools -curl -sSL https://github.com/pinterest/ktlint/releases/download/$KTLINT/ktlint +mkdir -p ../oppia-android-tools +cd ../oppia-android-tools +curl -sSLOC - https://github.com/pinterest/ktlint/releases/download/$KTLINT/ktlint chmod a+x ktlint echo Ktlint file downloaded