Skip to content

Commit bee838e

Browse files
author
Matthew Rothenberg
committed
fix regression in --email option and zero args
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
1 parent 9c6c7c0 commit bee838e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

bin/ka-clone

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def die_if_not_valid_git_repo():
8282

8383
def _default_email():
8484
try:
85-
return subprocess.check_output(["git", "config", "kaclone.email"])
85+
kac_email = subprocess.check_output(["git", "config", "kaclone.email"])
86+
return kac_email.rstrip()
8687
except subprocess.CalledProcessError:
8788
return os.environ['USER'] + "@" + DEFAULT_EMAIL_DOMAIN
8889

@@ -209,7 +210,7 @@ def _chomp(s, sep):
209210
def _cli_process_current_dir(cli_args):
210211
die_if_not_valid_git_repo()
211212
if not cli_args.no_email:
212-
set_email()
213+
set_email(args.email)
213214
if not cli_args.no_lint:
214215
install_commit_linter()
215216
if not cli_args.no_msg:
@@ -232,6 +233,10 @@ if __name__ == '__main__':
232233
# TODO(mroth): allow --repair to take an optional target
233234
_cli_process_current_dir(args)
234235
else:
236+
if not args.src:
237+
parser.print_help()
238+
sys.exit(0)
239+
235240
_dst = _clone_repo(args.src, args.dst, args.quiet)
236241
logging.info(
237242
"Configuring your cloned git repository with KA defaults..."

examples/errors.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ design decision, so those config files can continue to be updated as they have
4747
in the past, and existing global configurations will work--hence better reverse
4848
compatibility. Also, the user can find them to manually modify somewhere they
4949
might expect if they are old-school.)
50+
51+
52+
Regression test: providing --email at command line should always have
53+
precedence over any default email guesses:
54+
55+
$ ka-clone $REPO repowithcustomemail --email=me@you.com --no-lint --no-gitconfig --no-msg
56+
Cloning into 'repowithcustomemail'...
57+
.* (re)
58+
done.
59+
Configuring your cloned git repository with KA defaults...
60+
-> Set user.email to me@you.com
61+
$ cd repowithcustomemail && git config --local user.email
62+
me@you.com

0 commit comments

Comments
 (0)