Skip to content

Commit

Permalink
fix regression in --email option and zero args
Browse files Browse the repository at this point in the history
option —email at CLI once again has highest precedence.  added an
integration test for this instance to make sure it stays fixed.

also fixed a regression that had broken printing help by default when
given zero args.

Review: D18650

Auditors: csilvers, alpert
  • Loading branch information
Matthew Rothenberg committed Jun 17, 2015
1 parent 9c6c7c0 commit bee838e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/ka-clone
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def die_if_not_valid_git_repo():

def _default_email():
try:
return subprocess.check_output(["git", "config", "kaclone.email"])
kac_email = subprocess.check_output(["git", "config", "kaclone.email"])
return kac_email.rstrip()
except subprocess.CalledProcessError:
return os.environ['USER'] + "@" + DEFAULT_EMAIL_DOMAIN

Expand Down Expand Up @@ -209,7 +210,7 @@ def _chomp(s, sep):
def _cli_process_current_dir(cli_args):
die_if_not_valid_git_repo()
if not cli_args.no_email:
set_email()
set_email(args.email)
if not cli_args.no_lint:
install_commit_linter()
if not cli_args.no_msg:
Expand All @@ -232,6 +233,10 @@ if __name__ == '__main__':
# TODO(mroth): allow --repair to take an optional target
_cli_process_current_dir(args)
else:
if not args.src:
parser.print_help()
sys.exit(0)

_dst = _clone_repo(args.src, args.dst, args.quiet)
logging.info(
"Configuring your cloned git repository with KA defaults..."
Expand Down
13 changes: 13 additions & 0 deletions examples/errors.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ design decision, so those config files can continue to be updated as they have
in the past, and existing global configurations will work--hence better reverse
compatibility. Also, the user can find them to manually modify somewhere they
might expect if they are old-school.)


Regression test: providing --email at command line should always have
precedence over any default email guesses:

$ ka-clone $REPO repowithcustomemail --email=me@you.com --no-lint --no-gitconfig --no-msg
Cloning into 'repowithcustomemail'...
.* (re)
done.
Configuring your cloned git repository with KA defaults...
-> Set user.email to me@you.com
$ cd repowithcustomemail && git config --local user.email
me@you.com

0 comments on commit bee838e

Please sign in to comment.