mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-13 12:30:08 -06:00
Add --no-stash option.
This commit is contained in:
@@ -21,6 +21,7 @@ from pre_commit.jsonschema_extensions import remove_defaults
|
||||
from pre_commit.logging_handler import LoggingHandler
|
||||
from pre_commit.repository import Repository
|
||||
from pre_commit.staged_files_only import staged_files_only
|
||||
from pre_commit.util import noop_context
|
||||
|
||||
|
||||
logger = logging.getLogger('pre_commit')
|
||||
@@ -233,7 +234,12 @@ def run(runner, args, write=sys.stdout.write):
|
||||
logger.addHandler(LoggingHandler(args.color, write=write))
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
with staged_files_only(runner.cmd_runner):
|
||||
if args.no_stash:
|
||||
ctx = noop_context()
|
||||
else:
|
||||
ctx = staged_files_only(runner.cmd_runner)
|
||||
|
||||
with ctx:
|
||||
if args.hook:
|
||||
return _run_hook(runner, args.hook, args, write=write)
|
||||
else:
|
||||
|
||||
@@ -31,6 +31,10 @@ def run(argv):
|
||||
'--color', default='auto', type=color.use_color,
|
||||
help='Whether to use color in output. Defaults to `auto`',
|
||||
)
|
||||
run_parser.add_argument(
|
||||
'--no-stash', default=False, action='store_true',
|
||||
help='Use this option to prevent auto stashing of unstaged files.',
|
||||
)
|
||||
run_parser.add_argument('--verbose', '-v', action='store_true', default=False)
|
||||
|
||||
help = subparsers.add_parser('help', help='Show help for a specific command.')
|
||||
|
||||
@@ -62,3 +62,9 @@ def clean_path_on_failure(path):
|
||||
if os.path.exists(path):
|
||||
shutil.rmtree(path)
|
||||
raise
|
||||
|
||||
|
||||
# TODO: asottile.contextlib this with a forward port of nested
|
||||
@contextlib.contextmanager
|
||||
def noop_context():
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user