Skip to content

Commit

Permalink
Merge pull request #25 from autentia/feature/#184414444-demo-fixes
Browse files Browse the repository at this point in the history
[184414444] demo version 0.9.0 fixes
  • Loading branch information
ssubijana authored Feb 9, 2023
2 parents d264657 + 8ed82a5 commit 5b2a1af
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion TNTGitHook/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion TNTGitHook/misc/tnt_git_hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion TNTGitHook/pre_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
10 changes: 5 additions & 5 deletions pre_push_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@ 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"),
"#!/bin/bash\n"
"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([],
self.pre_push.remove_old_script_lines(["read local_ref local_sha remote_ref remote_sha",
"# 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",
"# Assumes tnt_git_hook.sh is on PATH",
"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__':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="TNTGitHook",
version="0.10.0",
version="0.9.1",
author="Autentia",
author_email="[email protected]",
description="Utility to auto impute activities in TNT",
Expand Down

0 comments on commit 5b2a1af

Please sign in to comment.