Re: [Spacewalk-devel] Proposed commit hook to catch suspicious merge commits
On Thu, Apr 16, 2009 at 09:51:33AM +0200, Jan Pazdziora wrote: Since there were no objections, I assume people have tested the code and are OK with it. I'm about to drop an email to fedora-infrastructure -- please shout now if you do not want to see that commit hook on Spacewalk upstream repository. For your information -- the hook was activated on Spacewalk git repository at ssh://git.fedorahosted.org/git/spacewalk.git/ now. If you try to push a commit which is a merge and has a commit message which looks like an automatic merge, you will get an error like this: $ git push Counting objects: 12, done. Compressing objects: 100% (7/7), done. Writing objects: 100% (7/7), 763 bytes, done. Total 7 (delta 5), reused 0 (delta 0) Commit [22709bf42f9effdc4dcc3acc31eb95c2952e3386] looks like automatic merge when you did not rebase after pull. To ssh://git.fedorahosted.org/git/spacewalk.git/ ! [remote rejected] master - master (pre-receive hook declined) error: hooks/pre-receive exited with error code 1 error: failed to push some refs to 'ssh://git.fedorahosted.org/git/spacewalk.git/' In other words: if you see this error, it's because you are try to to push merge without rebase. The fix is to rebase: $ git rebase origin/master First, rewinding head to replay your work on top of it... Applying: spacewalk-selinux: amend %changelog. ... review the result with $ gitk --all ... and if you are happy with the result, push: $ git push Counting objects: 9, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 481 bytes, done. Total 5 (delta 4), reused 0 (delta 0) To ssh://git.fedorahosted.org/git/spacewalk.git/ 15122b3..81ee3ac master - master $ -- Jan Pazdziora Senior Software Engineer, Satellite Engineering, Red Hat ___ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel
Re: [Spacewalk-devel] Proposed commit hook to catch suspicious merge commits
On Thu, Apr 02, 2009 at 10:54:21AM +0200, Jan Pazdziora wrote: On Thu, Mar 12, 2009 at 09:33:44AM -0300, Devan Goodwin wrote: Works for me. Yeah I'd be in favor of the commit hook. My first attempt at the hook which would catch commits that seems to be automatic merges done during git pull is in the attachment. Since there were no objections, I assume people have tested the code and are OK with it. I'm about to drop an email to fedora-infrastructure -- please shout now if you do not want to see that commit hook on Spacewalk upstream repository. -- Jan Pazdziora Senior Software Engineer, Satellite Engineering, Red Hat ___ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel
[Spacewalk-devel] Proposed commit hook to catch suspicious merge commits
On Thu, Mar 12, 2009 at 09:33:44AM -0300, Devan Goodwin wrote: Works for me. Yeah I'd be in favor of the commit hook. My first attempt at the hook which would catch commits that seems to be automatic merges done during git pull is in the attachment. -- Jan Pazdziora Senior Software Engineer, Satellite Engineering, Red Hat #!/bin/bash while read old_sha1 new_sha1 refname ; do # echo stdin: [$old_sha1] [$new_sha1] [$refname] git rev-list --parents $old_sha1..$new_sha1 \ | while read sha1 parents ; do # echo commit: [$sha1] [$parents] if [ ${parents/ /} != $parents ] ; then # echo- merge if ! ( git cat-file commit $sha1 \ | perl -e 'BEGIN { $/ = \n\n } scalar(); my $msg = ; if ($msg =~ /^Merge branch \S+ of \S+\n*$/s) { exit 1 }' ) ; then echo Commit [$sha1] looks like automatic merge when you did not rebase after pull. exit 1 fi fi done [ $? -ne 0 ] exit 1 : done exit $? ___ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel