elixirsc / git-pair

Automatically adds `Co-authored-by` mark when you're pairing
https://hex.pm/packages/git_pair
MIT License
8 stars 0 forks source link

Implement `init` action #3

Closed wevtimoteo closed 4 years ago

wevtimoteo commented 4 years ago

As described in README init action will be resposible to setup:

According with git-config docs:

You can query/set/replace/unset options with this command. The name is actually the section and the key separated by a dot, and the value will be escaped.

We can create this file under .git/hooks/pre-commit (investigate if can we append any suffix to it, such as pre-commit-append-coauthors)

Additional information

So there is no need to set up an empty key under .git/config, using --get-all it will return nothing in case of absence:

git config --get-all pair.coauthor
wevtimoteo commented 4 years ago

It seems it return a exit status 1:

$ git config --get-all pair.coauthor
$ echo $?
1
wevtimoteo commented 4 years ago

@amadeu01 and I investigated Git Hooks Documentation and we realized that we should use commit-msg instead pre-commit hook:

The commit-msg hook takes one parameter, which again is the path to a temporary file that contains the commit message written by the developer. If this script exits non-zero, Git aborts the commit process, so you can use it to validate your project state or commit message before allowing a commit to go through.