savannah-hackers-public
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Savannah-hackers-public] Savannah git policy - non-fast-forward and


From: Assaf Gordon
Subject: Re: [Savannah-hackers-public] Savannah git policy - non-fast-forward and branches
Date: Tue, 20 Jan 2015 15:56:29 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Hello Bob and all,

Here's my attempt at a git update hook which conditionally allows 
non-fast-forward commits on branches (and even 'master', based on 
configuration).

It works like this:

1.
By default, non-fast-forwards are not allowed.

Trying to push non-fast-forward to 'master' branch gives:
====
$ git push origin +master
Counting objects: 1, done.
Writing objects: 100% (1/1), 208 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
remote: *** Rejected: non-fast-forward on the master branch are disabled in 
Savannah.
remote:     See http://savannah.gnu.org/maintenance/XXXXXXX for details.
remote: error: hook declined to update refs/heads/master
To /home/gordon/projects/git-hook-test/orig-bare/
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 
'/home/gordon/projects/git-hook-test/orig-bare/'
====

Trying to push non-fast-forward to non-master branch gives:
====
$ git push origin +dev/test1
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (12/12), 968 bytes | 0 bytes/s, done.
Total 12 (delta 4), reused 0 (delta 0)
remote: *** Rejected: non-fast-forward on branches are disabled for this 
repository.
remote:     See http://savannah.gnu.org/maintenance/XXXXXXX for details.
remote: error: hook declined to update refs/heads/dev/test1
To /home/gordon/projects/git-hook-test/orig-bare/
 ! [remote rejected] dev/test1 -> dev/test1 (hook declined)
error: failed to push some refs to 
'/home/gordon/projects/git-hook-test/orig-bare/'
====

2.
Two configuration options control whether non-fast-forwards commits are allowed:
Setting this:
    git config hooks.allowbranchnonfastforward true
Will enable non-fast-forward commits to all non-master branch.

Setting this:
    git config hooks.allowbranchnonfastforward true
Will enable non-fast-forward commits to the master branch.
This will also send a notification email to a pre-configured email (e.g. 
sv-hk-private), to ensure such non-common events don't go unnoticed.

The email looks like this (not pretty, but informative):
===
This is an automated message.

The master branch of '/home/gordon/projects/git-hook-test/orig-bare' is being 
modified with a
non-fast-forward commit.
time: Tue, 20 Jan 2015 20:39:41 +0000
old-revision: 9f329a0388358af91ae194a6f4d4fcd640a1b117
new-revision: 31f645f6582e9763f5c9537568122cf4791b415a
===


Comments and improvements are welcomed,
 - Assaf

P.S.
Note that deleting branches is allowed without checking, as it is today.
Controlling branch deletion is also possible.



Attachment: update
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]