{pre,mid,post}-commit hooks?
John A Meinel
john at arbash-meinel.com
Mon Jan 16 23:02:49 GMT 2006
Charles Duffy wrote:
> I have need for functionality similar to the evil CVS $Id$ tag and kin,
> to ensure that the version number given in my .spec file (used for RPM
> builds) matches with "baz revno" for a given revision. (RPM needs to
> know the package version number *before* it unpacks the source tarball
> in full -- at a point when, in a "rpmbuild -tb" build, it's extracting
> only the spec file -- so I can't just let it call baz revno after the
> %prep step and calculate the version number that way).
>
> The closest thing I've come up with is having a pre-commit hook which
> either:
>
> - Runs through a sed expression or such to build a new spec file with
> the correct revision number from a template
> ...or, more cautiously...
> - Validates that the contents of the spec file matches the new
> revision-number-to-be and cancels the commit otherwise, but is allowed
> to make no changes.
>
> Without one of these two, I'll be fated to a life of "bzr uncommit"
> followed by twiddling and redoing the commit -- because I'm *not* going
> to remember to bump that number every time.
>
Why isn't it possible to add something to the build step? What is
creating the spec file that is supposed to keep it up-to-date? (as far
as I know $Id$ wouldn't do the right thing either anyway).
If you are truly doing a pre-commit hook, you can create a plugin which
decorates 'cmd_commit' so that it updates whatever you need before
running the real cmd_commit.
Something like this:
pre_commit.py
import bzrlib.builtins
from bzrlib.command import register_command
class cmd_commit(bzrlib.builtins.cmd_commit):
def run(self, *args, **kwargs):
# At this point you exist before cmd_commit has been called
# do something
return bzrlib.builtins.cmd_commit(*args, **kwargs)
I know we have discussed adding pre/post/mid commit hooks. I just think
nobody has gotten around to it.
I did write a plugin which can generate lots of version information
about all the files in your source tree:
http://bzr.arbash-meinel.com/plugins/version_info/
But that is designed to be run as part of a build step, not before/after
commit.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060116/dcffd38e/attachment.pgp
More information about the bazaar
mailing list