Skip to content

Commit

Permalink
Rework elegant configure` command
Browse files Browse the repository at this point in the history
Issue #130 implemented
1. git elegant configure renamed to configure-repository
2. command git configure-repository works like git elegant configure --local
3. Tests and README updated
  • Loading branch information
alexbeatnik committed Jun 6, 2019
1 parent fdcc90a commit deaefad
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 99 deletions.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Adds file contents to the index interactively.
### clear-local
Removes all local branches which don't have remote tracking branches.

### configure
Defines some settings for both _global_ and _local_ `git config`.
### configure-repository
Defines some settings for _local_ `git config`.

### check
Shows trailing whitespaces of uncommitted changes.
Expand Down
2 changes: 1 addition & 1 deletion src/main/git-elegant-acquire-repository
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ default() {
_validate "$1" "Cloneable URL"
boxtee git clone "$1"
cd $(basename -s .git $1)
git elegant configure --local
git elegant configure-repository
}
2 changes: 1 addition & 1 deletion src/main/git-elegant-commands
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default() {
echo "acquire-repository"
echo "add"
echo "clear-local"
echo "configure"
echo "configure-repository"
echo "check"
echo "save"
}
3 changes: 0 additions & 3 deletions src/main/git-elegant-completion
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ _git_elegant() {
push|epush)
COMPREPLY=( $(compgen -W "$(git branch | grep \* | cut -d ' ' -f2)" ${cur}) )
return 0 ;;
configure|econfigure)
COMPREPLY=($(compgen -W '--global --local' -- ${cur}) )
return 0 ;;
check|echeck)
COMPREPLY=($(compgen -W '"--all" "--unstaged" "--staged"' -- ${cur}) )
return 0 ;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ _alias_message="add git aliases for all 'elegant git' commands"


_configure() {
MODE=$1; shift
FUNCTIONS=$@
for f in ${FUNCTIONS[@]}; do
unset answer
Expand All @@ -42,25 +41,18 @@ _configure() {
for com in $(git elegant commands); do
alias="e${com}"
command="elegant $com"
boxtee git config $MODE $(eval "echo -n \$${f}_key\$alias") "$command"
boxtee git config --local $(eval "echo -n \$${f}_key\$alias") "$command"
done
fi
else
if [ -n "${answer}" ]; then
boxtee git config $MODE $(eval "echo -n \$${f}_key") "$answer"
boxtee git config --local $(eval "echo -n \$${f}_key") "$answer"
fi
fi
done
done
}

GLOBALS=(_user_name _user_email _core_comment_char _apply_whitespace _alias)
LOCALS=(_user_name _user_email _core_comment_char _apply_whitespace)

default() {
case "$1" in
--global) _configure --global ${GLOBALS[@]} ;;
--local) _configure --local ${LOCALS[@]} ;;
*) exit 11 # @todo #9 Add usage message if mandatory argument is not set for `git-elegant configure`.
esac
_configure _user_name _user_email _core_comment_char _apply_whitespace
}
2 changes: 1 addition & 1 deletion src/main/git-elegant-init
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ set -e

default() {
boxtee git init
git elegant configure --local
git elegant configure-repository
}
2 changes: 1 addition & 1 deletion src/test/git-elegant-acquire-repository.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ load addons-fake
setup() {
fake-pass git acquire-repository
fake-pass git "clone https://github.com/extsoft/elegant-git.git"
fake-pass git "elegant configure --local"
fake-pass git "elegant configure-repository"
}

teardown() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/git-elegant-commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ teardown() {
[ "${lines[6]}" = "acquire-repository" ]
[ "${lines[7]}" = "add" ]
[ "${lines[8]}" = "clear-local" ]
[ "${lines[9]}" = "configure" ]
[ "${lines[9]}" = "configure-repository" ]
[ "${lines[10]}" = "check" ]
[ "${lines[11]}" = "save" ]
[ ${#lines[@]} -eq 12 ]
Expand Down
37 changes: 37 additions & 0 deletions src/test/git-elegant-configure-repository.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bats

load addons-common
load addons-read
load addons-fake
load addons-git

fake-preconditions() {
fake-pass git "elegant commands"

fake-pass git "config user.name" "UserName"
fake-pass git "config user.email" "UserEmail"

fake-pass git "config --local core.commentChar"


fake-pass git "config --local user.name UserName"
fake-pass git "config --local user.email UserEmail"

fake-pass git "config --local apply.whitespace fix"
}

teardown() {
clean-fake
clean-git
}


@test "'configure-repository': sequence of the local git configuration is correct" {
init-repo
check git-elegant configure-repository
[ "${lines[0]}" = "your user name [Elegant Git]: " ]
[ "${lines[4]}" = "your user email [[email protected]]: " ]
[ "${lines[8]}" = "commit message won't start with [|]: " ]
[ "${lines[12]}" = "whitespace issues on patching [fix]: " ]
[ ${#lines[@]} -eq 16 ]
}
77 changes: 0 additions & 77 deletions src/test/git-elegant-configure.bats

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/git-elegant-init.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ load addons-fake

setup() {
fake-pass git init
fake-pass git "elegant configure --local"
fake-pass git "elegant configure-repository"
}

teardown() {
Expand Down

1 comment on commit deaefad

@0pdd
Copy link

@0pdd 0pdd commented on deaefad Jun 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 9-dbf97594 disappeared from src/main/git-elegant-configure, that's why I closed #117. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.