# SPDX-License-Identifier: LGPL-3.0-only """Plug-in module to store requirements in a Git repository.""" from doorstop import common from doorstop.core.vcs.base import BaseWorkingCopy log = common.logger(__name__) class WorkingCopy(BaseWorkingCopy): """Git working copy.""" DIRECTORY = '.git' IGNORES = ('.gitignore',) def lock(self, path): log.debug("`git` does not support locking: %s", path) self.call('git', 'pull') def edit(self, path): self.call('git', 'add', self.relpath(path)) def add(self, path): self.call('git', 'add', self.relpath(path)) def delete(self, path): self.call('git', 'rm', self.relpath(path), '--force', '--quiet') def commit(self, message=None): message = message or input("Commit message: ")
"""Shared functions for the `doorstop.cli` package.""" import os import ast from argparse import ArgumentTypeError import logging from doorstop import common from doorstop import settings log = common.logger(__name__) class capture(object): # pylint: disable=R0903 """Context manager to catch :class:`~doorstop.common.DoorstopError`.""" def __init__(self, catch=True): self.catch = catch self._success = True def __bool__(self): return self._success def __enter__(self): return self def __exit__(self, exc_type, exc_value, traceback): if exc_type and issubclass(exc_type, common.DoorstopError): self._success = False if self.catch: log.error(exc_value)