That's very useful, thanks for sharing! On Fri, May 15, 2015 at 4:37 PM, Michael Terry <[email protected]> wrote: > I use an unenlightened editor that doesn't run gofmt upon saving a file. > > So to avoid rookie mistakes, I wrote this tiny bzr hook to run gofmt during > a bzr commit (only for snappy branches). If you like it too, save it as > ~/.bazaar/plugins/gofmt.py > > """ > from bzrlib import hooks > > def run_gofmt(local, master, old_revno, old_revid, future_revno, > future_revid, tree_delta, future_tree): > import os, subprocess > from bzrlib import errors, workingtree > basedir = workingtree.WorkingTree.open(master.user_url).basedir > if os.path.exists(basedir + "/cmd/snappy/main.go") and > subprocess.check_output(["gofmt", "-l", basedir]): > raise errors.BzrError("Run gofmt, you have style errors.") > > hooks.install_lazy_named_hook('bzrlib.branch', 'Branch.hooks', > 'pre_commit', run_gofmt, 'Run gofmt on snappy branches') > """ > > -- > -mt > > -- > snappy-devel mailing list > [email protected] > Modify settings or unsubscribe at: > https://lists.ubuntu.com/mailman/listinfo/snappy-devel >
-- snappy-devel mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/snappy-devel
