Skip to content

Commit

Permalink
Use empty user's name and email if git doesn't know them
Browse files Browse the repository at this point in the history
For the new git installations the "user.name" and "user.email" settings
may not be configured. As the result, if a user tries to use "git
elegant configure ..." directly or as part of another command ("init"
etc.), it leads to a breaking of "configure" execution since default
setting can't be read.

As a solution, an empty value will be used by default in the case of the
"user.name" and "user.email" aren't configured on a global level.

#110
  • Loading branch information
extsoft committed May 9, 2018
1 parent ee454fc commit 00fda48
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/git-elegant-configure
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ _core_comment_char_default="|"
_core_comment_char_message="commit message won't start with"

_user_name_key="user.name"
_user_name_default=$(git config "$_user_name_key")
_user_name_default=$(git config "$_user_name_key" || echo '')
_user_name_message="your user name"

_user_email_key="user.email"
_user_email_default=$(git config "$_user_email_key")
_user_email_default=$(git config "$_user_email_key" || echo '')
_user_email_message="your user email"

_apply_whitespace_key="apply.whitespace"
Expand Down
8 changes: 8 additions & 0 deletions src/test/git-elegant-configure.bats
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,11 @@ teardown() {
[ "${lines[12]}" = "whitespace issues on patching [fix]: " ]
[ ${#lines[@]} -eq 16 ]
}

@test "'configure': command works if both 'user.name' and 'user.email' are absent" {
# move to the directory without the ".git/"
cd /tmp
# force "11" exit code - means all internal vars are initialised (including 'user.name' and 'user.email')
check git-elegant configure
[ "$status" -eq 11 ]
}

0 comments on commit 00fda48

Please sign in to comment.