From 9ff08817051893fca3853beb0293fafa729aa0ba Mon Sep 17 00:00:00 2001 From: Sara Subijana Gracia Date: Thu, 9 Feb 2023 14:05:49 +0100 Subject: [PATCH 1/3] [184414444] References tnt_git_hook script from pre-push file using home path variable --- TNTGitHook/pre_push.py | 2 +- pre_push_test.py | 10 +++++----- setup.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TNTGitHook/pre_push.py b/TNTGitHook/pre_push.py index 3f0cfa3..4e952b4 100644 --- a/TNTGitHook/pre_push.py +++ b/TNTGitHook/pre_push.py @@ -13,7 +13,7 @@ class PrePush: shebang: str = '#!/bin/bash' pipefail: str = 'set -o pipefail' readline: str = 'read local_ref local_sha remote_ref remote_sha' - tnt_call: str = f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)" + tnt_call: str = f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)" old_script_to_delete: List[str] = ['set -o pipefail', 'PROJECT_PATH', 'tnt_git_hook', 'read local_ref local_sha remote_ref remote_sha'] diff --git a/pre_push_test.py b/pre_push_test.py index 658b2a2..d39f04e 100644 --- a/pre_push_test.py +++ b/pre_push_test.py @@ -29,14 +29,14 @@ def test_the_pre_push_string_is_correct(self): "#!/bin/bash\n" "set -o pipefail\n" "read local_ref local_sha remote_ref remote_sha\n" - f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)") + f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)") def test_the_pre_push_string_is_correct_when_there_are_more_elements(self): self.assertTrue(self.pre_push.is_pre_push_correct( "#!/bin/bash\n" "read local_ref local_sha remote_ref remote_sha\n" "npm run test:ci\n" - f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)")) + f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)")) def test_the_pre_push_is_composed_correctly(self): self.assertEqual(self.pre_push.compose_pre_hook("#!/bin/sh\nnpm run test:ci"), @@ -44,7 +44,7 @@ def test_the_pre_push_is_composed_correctly(self): "set -o pipefail\n" "read local_ref local_sha remote_ref remote_sha\n" "npm run test:ci\n" - f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)") + f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $(git rev-parse --show-toplevel)") def test_old_lines_are_removed(self): self.assertListEqual([], @@ -52,7 +52,7 @@ def test_old_lines_are_removed(self): "# Assumes tnt_git_hook.sh is on PATH", "PROJECT_PATH=$(git rev-parse --show-toplevel)", "set -o pipefail", - f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $PROJECT_PATH"])) + f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $PROJECT_PATH"])) self.assertListEqual(["npm run test:ci"], self.pre_push.remove_old_script_lines(["read local_ref local_sha remote_ref remote_sha", @@ -60,7 +60,7 @@ def test_old_lines_are_removed(self): "npm run test:ci", "PROJECT_PATH=$(git rev-parse --show-toplevel)", "set -o pipefail", - f"{hook_installation_path()}tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $PROJECT_PATH"])) + f"$HOME/.tnt/hook/bin/tnt_git_hook $local_ref $local_sha $remote_ref $remote_sha $PROJECT_PATH"])) if __name__ == '__main__': diff --git a/setup.py b/setup.py index 0f75c88..2a6b6eb 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="TNTGitHook", - version="0.10.0", + version="0.9.1", author="Autentia", author_email="desktop.support@autentia.com", description="Utility to auto impute activities in TNT", From 4fee095b00ce106e9b5fa104e3f788ca0bc5a531 Mon Sep 17 00:00:00 2001 From: Sara Subijana Gracia Date: Thu, 9 Feb 2023 14:08:38 +0100 Subject: [PATCH 2/3] [184414444] Deletes not-useful flag --- TNTGitHook/hook.py | 1 - 1 file changed, 1 deletion(-) diff --git a/TNTGitHook/hook.py b/TNTGitHook/hook.py index 33e6480..0ded83f 100644 --- a/TNTGitHook/hook.py +++ b/TNTGitHook/hook.py @@ -146,7 +146,6 @@ def removes_old_hook_file(): try: exists = os.path.exists("/usr/local/bin/tnt_git_hook") if exists: - print("The file exists. Trying to remove") os.remove("/usr/local/bin/tnt_git_hook") except Exception as ex: print(ex) From 8ed82a530451ab045c69db78f153bdf819eddf6b Mon Sep 17 00:00:00 2001 From: Sara Subijana Gracia Date: Thu, 9 Feb 2023 14:09:34 +0100 Subject: [PATCH 3/3] [184414444] Formats list of tags when pushing all --- README.md | 2 +- TNTGitHook/misc/tnt_git_hook.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3cb0339..3b3a370 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ git_exit=$? if [ ! -s $filename ] then # If there aren't commits to push, checks if is a tagged commit and then generate a custom evidence - tag=$(git tag --points-at $local_sha) + tag=$(git tag --points-at $local_sha | xargs) if [ -n "$tag" ] then git log --pretty="format:%H;%aI;%an <%ae>;tag: ${tag}" -1 -U $local_sha 1> $filename diff --git a/TNTGitHook/misc/tnt_git_hook.sh b/TNTGitHook/misc/tnt_git_hook.sh index d57deb3..a30eba0 100755 --- a/TNTGitHook/misc/tnt_git_hook.sh +++ b/TNTGitHook/misc/tnt_git_hook.sh @@ -29,7 +29,7 @@ git_exit=$? if [ ! -s $filename ] then # If there aren't commits to push, checks if is a tagged commit and then generate a custom evidence - tag=$(git tag --points-at $local_sha) + tag=$(git tag --points-at $local_sha | xargs) if [ -n "$tag" ] then git log --pretty="format:%H;%aI;%an <%ae>;tag: ${tag}" -1 -U $local_sha 1> $filename