[PATCH v4] nmbug: Add an 'init' command

W. Trevor King wking at tremily.us
Mon Jan 19 08:55:35 PST 2015


On Mon, Jan 19, 2015 at 11:44:16AM +0200, Tomi Ollila wrote:
> $ python2.7 devel/nmbug/nmbug init
> Reinitialized existing Git repository in /home/too/.nmbug/
> e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
> user.name not defined
> [u'git', u'--git-dir', u'/home/too/.nmbug', u'commit', u'--allow-empty',
> u'-m', u'Start a new nmbug repository'] exited with 1
> zsh: exit 1     python2.7 devel/nmbug/nmbug init
> 
> This is due to my default /path/to/git-templates/pre-commit
> forbidding commits unless I've configured user.name & user.email for
> that particular repository....
> 
> I guess there is not much one can do to handle users' mystic global
> hooks -- I'll look (later) whether e.g. '--no-hooks' parameter could
> be given to nmbug from command line...
> 
> ... Ok, it was --no-verify and patching that to the command line
> worked -- git complained that "Your name and email address were
> configured automatically based on your username and hostname..."…

Hmm.  My initial feeling is that if your pre-commit hook doesn't want
you to commit, we should respect that.  Although I'm not sure how to
handle this case for folks like you that don't define a global
username or email address.  Possibilities:

* Drop the empty commit from ‘nmbug init’ and teach ‘nmbug log’,
  ‘status’, ‘commit’, etc. to handle the “we don't have any commits
  yet” case?  That gives you time between the init and first commit to
  go into the repository and setup your username and email address by
  hand.  This would be the most work, but gives us a more native
  solution (‘nmbug init’ maps more directly to ‘git init’).

* Adjust the syntax to:

    nmbug init -- {arguments passed through to ‘git commit’}

  so you could run:

    nmbug init -- --author 'A U Thor <author at example.com>'

  or:

    nmbug init -- --no-verify

  this works as long as the tweak you need is accessible from a ‘git
  commit’ argument (I guess --no-verify covers us there).

> … but commit succeeded :).

From the template pre-commit.sample:

  The hook should exit with non-zero status after issuing an
  appropriate message if it wants to stop the commit.

so you should check that your hook is doing that if you expect to
abort commits it doesn't like ;).

> I think it should be checked so that init on already-existing
> repository does not succeed.

Good point.  I've added:

  if _os.path.exists(NMBGIT):
      raise ValueError('NMBGIT path ({!r}) already exists'.format(NMBGIT))

for v5.

Cheers,
Trevor

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20150119/36bcd9e8/attachment.pgp>


More information about the notmuch mailing list