from urllib import unquote as _unquote
-__version__ = '0.2'
+__version__ = '0.3'
_LOG = _logging.getLogger('nmbug')
-_LOG.setLevel(_logging.ERROR)
+_LOG.setLevel(_logging.WARNING)
_LOG.addHandler(_logging.StreamHandler())
NMBGIT = _os.path.expanduser(
TAG_PREFIX = _os.getenv('NMBPREFIX', 'notmuch::')
_HEX_ESCAPE_REGEX = _re.compile('%[0-9A-F]{2}')
-_TAG_FILE_REGEX = _re.compile('tags/(?P<id>[^/]*)/(?P<tag>[^/]*)')
+_TAG_DIRECTORY = 'tags/'
+_TAG_FILE_REGEX = _re.compile(_TAG_DIRECTORY + '(?P<id>[^/]*)/(?P<tag>[^/]*)')
# magic hash for Git (git hash-object -t blob /dev/null)
_EMPTYBLOB = 'e69de29bb2d1d6434b8b29ae775ad8c2e48c5391'
'git', 'clone', '--no-checkout', '--separate-git-dir', NMBGIT,
repository, workdir],
wait=True)
- _git(args=['config', '--unset', 'core.worktree'], wait=True)
+ _git(args=['config', '--unset', 'core.worktree'], wait=True, expect=(0, 5))
_git(args=['config', 'core.bare', 'true'], wait=True)
_git(args=['branch', 'config', 'origin/config'], wait=True)
+ existing_tags = get_tags()
+ if existing_tags:
+ _LOG.warning(
+ 'Not checking out to avoid clobbering existing tags: {}'.format(
+ ', '.join(existing_tags)))
+ else:
+ checkout()
def _is_committed(status):
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)