Re: Anyone have a commit hook for forbidding old branches from being merged in?

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

 



Ævar Arnfjörð Bjarmason wrote:
> 
> So before I write a hook to do this, is there anything that implements
> a hook that:
> 
>  * Checks if you're pushing a merge commit
>  * If so, is that merge based off and old version of $MAINBRANCH

I think it suffices to check whether any boundary commit in the
updated range is older than what you allow, e.g.

while read old new rev; do
    # omitted: check it's an update, i.e., neither old nor new is 0..0
    git rev-list --boundary $old..$new |
    sed -n 's/^-//p' |
    xargs git rev-list --no-walk --before='cutoff limit' >bad
    test -s bad || exit 1
done

(Not tested much; in particular I'm not sure you can get away without
limiting the number of args to rev-list to 1.  A simple test seems to
indicate so, however.)

-- 
Thomas Rast
trast@{inf,student}.ethz.ch
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]