X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=devel%2Fnmbug%2Fnmbug;h=043c186369c1f55fce114b230746f138d7bc2345;hb=15d8067c0a209a24d757b416107d92007529f01f;hp=0cd911487a80b950090566cd4d3c41adfb91f484;hpb=7ef3b65376b87829441736f04b3231021f561d84;p=notmuch diff --git a/devel/nmbug/nmbug b/devel/nmbug/nmbug index 0cd91148..043c1863 100755 --- a/devel/nmbug/nmbug +++ b/devel/nmbug/nmbug @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2011-2014 David Bremner # W. Trevor King @@ -51,7 +51,7 @@ except ImportError: # Python 2 from urllib import unquote as _unquote -__version__ = '0.2' +__version__ = '0.3' _LOG = _logging.getLogger('nmbug') _LOG.setLevel(_logging.WARNING) @@ -65,7 +65,8 @@ if _os.path.isdir(_NMBGIT): TAG_PREFIX = _os.getenv('NMBPREFIX', 'notmuch::') _HEX_ESCAPE_REGEX = _re.compile('%[0-9A-F]{2}') -_TAG_FILE_REGEX = _re.compile('tags/(?P[^/]*)/(?P[^/]*)') +_TAG_DIRECTORY = 'tags/' +_TAG_FILE_REGEX = _re.compile(_TAG_DIRECTORY + '(?P[^/]*)/(?P[^/]*)') # magic hash for Git (git hash-object -t blob /dev/null) _EMPTYBLOB = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391' @@ -683,8 +684,11 @@ def _unpack_diff_lines(stream): for line in stream: match = _TAG_FILE_REGEX.match(line.strip()) if not match: - raise ValueError( - 'Invalid line in diff: {!r}'.format(line.strip())) + message = 'non-tag line in diff: {!r}'.format(line.strip()) + if line.startswith(_TAG_DIRECTORY): + raise ValueError(message) + _LOG.info(message) + continue id = _unquote(match.group('id')) tag = _unquote(match.group('tag')) yield (id, tag)