This commit is contained in:
8geese
2015-05-03 22:09:51 -07:00
committed by caffodian
parent cdf726bbed
commit fdc2a889de
3 changed files with 86 additions and 0 deletions

View File

@@ -139,6 +139,18 @@ def _has_unmerged_paths(runner):
return bool(stdout.strip())
def _has_unstaged_config(runner):
retcode, stdout, stderr = runner.cmd_runner.run(
[
'git', 'diff', '--exit-code', runner.config_file_path
],
retcode=None,
encoding=None,
)
# be explicit, other git errors don't mean it has an unstaged config.
return retcode == 1
def run(runner, args, write=sys_stdout_write_wrapper, environ=os.environ):
# Set up our logging handler
logger.addHandler(LoggingHandler(args.color, write=write))
@@ -151,6 +163,16 @@ def run(runner, args, write=sys_stdout_write_wrapper, environ=os.environ):
if bool(args.source) != bool(args.origin):
logger.error('Specify both --origin and --source.')
return 1
if _has_unstaged_config(runner) and not args.no_stash:
if args.allow_unstaged_config:
logger.warn('You have an unstaged config file and have '
'specified the --allow-unstaged-config option.\n'
'Note that your config will be stashed before the '
'config is parsed unless --no-stash is specified.')
else:
logger.error('You have an unstaged config file and have not '
'specified the --allow-unstaged-config option.\n')
return 1
# Don't stash if specified or files are specified
if args.no_stash or args.all_files or args.files:

View File

@@ -94,6 +94,11 @@ def main(argv=None):
'--source', '-s',
help='The remote branch"s commit_id when using `git push`',
)
run_parser.add_argument(
'--allow-unstaged-config', default=False, action='store_true',
help='Allow an unstaged config to be present. Note that this will'
'be stashed before parsing unless --no-stash is specified'
)
run_mutex_group = run_parser.add_mutually_exclusive_group(required=False)
run_mutex_group.add_argument(
'--all-files', '-a', action='store_true', default=False,