aau-network-security / richkit

Domain Enrichment Toolkit $ pip install richkit
https://pypi.org/project/richkit/
MIT License
11 stars 3 forks source link

define git hooks for better git branch names #29

Closed mrtrkmn closed 4 years ago

mrtrkmn commented 5 years ago

There should some name conventions in order to get out from a situation where everything is messed up. This issue could be closed by creating customised git hooks which might run on server and client side.

mrtrkmn commented 5 years ago

Please pull following pre-commit hook and change with your local hooks. (under project root)


 $ cd .git/hooks/
 $ wget https://gist.githubusercontent.com/mrturkmen06/b44c09df3a86286d017cdd3a01e4f87c/raw/bfbf98cae8936cc964e596489d846093d8757f70/pre-commit.sh 
 $ mv pre-commit.sh pre-commit
 $ chmod +x pre-commit
kidmose commented 5 years ago

I can confirm that it blocks branchnames test and testtesttesttesttesttesttest (len=28).

It seems that it would be beneficial to add a check on whether the name matches your regex on pre-commit.sh:6, because the two names above are simply not caught on by that, thus it reports a length of 0 and prints some misleading messages.

Are we testing or is this the intended mean of deploying the hook? :) (I was hoping that the hooks would just live in the repo, but we then of course have the problems of mixed dev platforms..)

kidmose commented 5 years ago

I had a look at e.g. https://www.viget.com/articles/two-ways-to-share-git-hooks-with-your-team/ and learned some about the challenges of centrally manages git hooks. I suggest we take the git config core.hooksPath .githooks-based approach described there, combined with a GH Actions step that runs the same hook. That way enabling the hooks in our local dev repos is optional and setup is done once, with updates trickling down automatically, but adherence to the rules of the hook is enforced centrally before merge.

mrtrkmn commented 4 years ago

https://stackoverflow.com/questions/22100581/github-server-side-git-hooks-i-e-pre-commit-and-post-commit

:(

kidmose commented 4 years ago

With Travis you have $TRAVIS_PULL_REQUEST_BRANCH available. Suppose you have you hooks as shell scripts in e.g. .githooks/test_branch_name.sh. Then on travis I believe you can test with this command:

./.githooks/test_branch_name.sh --name=$TRAVIS_PULL_REQUEST_BRANCH

Or not?

https://graysonkoonce.com/getting-the-current-branch-name-during-a-pull-request-in-travis-ci/