github - GIT HOOK to check keyword "PROMOTE" in message when GIT MERGE is executed -


i need check "promote" keyword in message whenever there merge master , other branch

eg: if git command is:
git merge -m "merge commit 1 branch1 master" f145cd536463e595f1e4306eeec6f92a9cd6c734 merge should exit error "promote key word not set in merge message"

git merge -m "promote commit 1 branch1 master" f145cd536463e595f1e4306eeec6f92a9cd6c734 merge should successful.

the problem merge command is not guaranteed create commit unless use --no-ff. example might following result command.

git merge  -m "merge commit 1  branch1 master" updating f145cd5..cd6c734 fast-forward (no commit created; -m option ignored) 

see post , pdf great explanation of fast-forward vs no fast-forward when merging. people think -no-ff muddies history , breaks git-bisect , git blame. others love --no-ff because allows merge comments , visualization of happened in feature branch.

if decide use --no-ff, can configure git to --no-ff globally or on per branch basis. use command configure --no-ff on master only.

git config branch.master.mergeoptions  "--no-ff" 

let's original problem.

git supports hooks can used verification , work flow. hooks can run @ local client or server developers push changes. regular expression using client hook commit-msg, one, seems perfect. git does not have pre-merge hook use reject merge. see here list of hooks , triggering commands. worse notice git merge not trigger of hooks if force commit --no-ff.

so have 2 choices. same mentioned in post explores topic further no better solutions.

  • put update hook, one, on git server developers pushing. problem approach doesn't keep them making bad comments. approach keeps bad comments off server. developers have lot of work in fixing history before can push server if don't right first time.
  • write (and distribute, , maintain...) git-merge wrapper control @ local repo level. michael j gruber has pre-merge hook in git fork here.

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -