2

My project uses a single gitHub repository in which both Mac and Windows users commit their code on. I have set up a client side hook in order to include the JIRA Id in the commit message by modifying the commit-message hook in the hooks folder. However, as client side hooks cannot be published, writing a script and including it in the repo would help modify the file. Is it possible to write a common script that would work on both windows and Mac. The script needs to do the following.

  • Rename the commit-msg.sample to commit-msg
  • Replace the contents of the file to the code below

Code below

 commit_regex='(ISSUE-[0-9]+|merge)'
 error_msg="Aborting commit. Your commit message is missing either a JIRA      Issue ('ISSUE-1111') or 'Merge'"

if ! grep -iqE "$commit_regex" "$1"; then
echo "$error_msg" >&2
exit 1
fi
1
  • Use a portable solution, e.g. Perl or Java? Commented Jan 6, 2017 at 9:44

1 Answer 1

1

Is it possible to write a common script that would work on both windows and Mac

You simply can write a bash script: it will be interpreted by the Git bash, which does exists even on Windows.

Any executable script starting with #!/bin/bash will do.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.