Re: Anyone have a commit hook for forbidding old branches from being merged in?
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Dec 1, 2011, 15:50 UTC
- Message-ID
- <201112011650.51547.trast@student.ethz.ch>
- In-Reply-To
- <CACBZZX4LyTaz=fU1vvgpeL904QFjJULCMVSP0uutcuxZT+-vWQ@mail.gmail.com>
Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> > 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