previously i threw together a small hook to make it a bit easier to avoid duplicate work while maintaining packages, as well as easily keep the BTS up to date with relevant information.
now i've commonized the code just a bit and have a second hook which can be used to maintain certian (what i believe to be) good practices for keeping packages in git. admittedly, it's a bit more "stick" than "carrot" with respect to streamlining workflows, but i feel the justifications and the resulting benefits are worth it.
so the hook does basically two things, either of which can be customized and/or disabled.
prevent "non-debian" changes on a "debian" branch
assuming that there are seperate branches for "debian" packaging and for "upstream" development, this hook prevents upstream-style changes on the debian branches. that is to say changes to files outside ./debian are not permitted on a "debian" branch, unless of course you're merging from an upstream branch.
instead, changes to the source in a debian branch should be managed by quilt-style "feature patches", or a more advanced branch topology using some kind of feature branches (topgit or similar).
prevent changelog modifications from being mixed in with other commits
this one might be a bit more controversial for some. basically, the idea is that:
- stuff is fixed in a commit
- there is a log message for this commit, which contains a description of the fix
- the changelog update is redundant information to this log
- it's impossible to merge/cherry-pick/revert the fix later if the changelog gets tangled into the commit.
- there are nice tools (git dch) for managing debian/changelog updates anyway.
therefore, this hook "declines" commits which modify debian/changelog, unless it is the only file being changed.
using this new hook
note this is the same repo as the other hook, so if you already have that set up you can skip the clone and instead just pull in the changes.
to set it up:
REPO_PATH=/path/to/your/repo.git
HOOK_REPO_PATH=/somewhere/you/want/to/put/it
git clone git://git.debian.org/users/seanius/vcs-hooks/git-hooks.git $HOOK_REPO_PATH
ln -sf $HOOK_REPO_PATH/debian/git-hooks/pre-receive-fileset-fascism.py $REPO_PATH/hooks/pre-receive
the config options for controlling this hook (these are git config options just like the other hook):
# hooks.debianbranches (default: 'debian-.*')
# a regular expression which indicates which branches are "debian" branches.
# in the context of this hook such branches are not allowed to have changes
# in files outside of the ./debian directory.
# hooks.sacredchangelog (default: True)
# if set to True, debian/changelog can not be changed in a commit that
# also modifies other files. this helps ensure changes that are easily
# merged/cherry-picked/reverted.
examples of the hook in action
rejecting a commit that has an entangled changelog:
rangda[~/debian/php] git push :)
Counting objects: 9, done.
Delta compression using 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 442 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
fileset-fascism rejecting commit 2fab3269b3d9daedd7013a576483a11ccb4cb86a
debian/changelog must be changed seperately from other files.
changed files in this commit:
debian/changelog
debian/control
error: hooks/pre-receive exited with error code 1
To ssh://git.debian.org/git/pkg-php/php.git
! [remote rejected] debian-sid -> debian-sid (pre-receive hook declined)
error: failed to push some refs to 'ssh://git.debian.org/git/pkg-php/php.git'
rejecting a commit that has non ./debian changes:
rangda[~/debian/php] git push :)
Counting objects: 5, done.
Delta compression using 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 309 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
fileset-fascism rejecting commit d96669c0780e33b250af81404e263fc181fe0547
non ./debian changes on a debian branch in this commit.
error: hooks/pre-receive exited with error code 1
To ssh://git.debian.org/git/pkg-php/php.git
! [remote rejected] debian-sid -> debian-sid (pre-receive hook declined)
error: failed to push some refs to 'ssh://git.debian.org/git/pkg-php/php.git'
as always, comments/feedback/suggestions/etc welcome 