-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The command allows applying the required configuration to a Git installation. Since there are some interceptionsbetween the `acquire-git` and `acquire-repository`, there are some changes in the overall configuration workflow. These changes are desribed on the documentation. Also, to prevent unexpected tests failures, the `~/.gitconfig` is removed after each test where a real Git repository is used. #177
- Loading branch information
Showing
11 changed files
with
227 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
command-purpose() { | ||
cat <<MESSAGE | ||
Configures a Git installation. | ||
MESSAGE | ||
} | ||
|
||
command-synopsis() { | ||
cat <<MESSAGE | ||
usage: git elegant acquire-repository | ||
MESSAGE | ||
} | ||
|
||
command-description() { | ||
cat<<MESSAGE | ||
Applies the "basics", "standards", and "aliases" configurations to the current | ||
Git installation using \`git config --global\`. | ||
To find out what will be configured, please visit | ||
${__site}/en/latest/configuration/ | ||
MESSAGE | ||
} | ||
|
||
default() { | ||
source ${BINS}/plugins/configuration | ||
basics-configuration --global user_name user_email core_editor | ||
standards-configuration --global \ | ||
core_comment \ | ||
apply_whitespace \ | ||
fetch_prune \ | ||
fetch_pruneTags \ | ||
core_autocrlf_darwinlinux \ | ||
core_autocrlf_windows pull_rebase \ | ||
rebase_autoStash \ | ||
credential_helper_darwin \ | ||
acquired | ||
aliases-removing --global | ||
aliases-configuration --global $(git elegant commands) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env bats | ||
|
||
load addons-common | ||
load addons-read | ||
load addons-fake | ||
load addons-repo | ||
|
||
setup() { | ||
repo-new | ||
} | ||
|
||
teardown() { | ||
fake-clean | ||
repo-clean | ||
} | ||
|
||
@test "'acquire-git': all configurations work as expected" { | ||
check git-elegant acquire-git | ||
[[ "${status}" -eq 0 ]] | ||
} | ||
|
||
@test "'acquire-git': basics are configured as expected" { | ||
check git-elegant acquire-git | ||
[[ "${lines[@]}" =~ "What is your user name? {Elegant Git}: " ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global user.name Elegant Git" ]] | ||
[[ "${lines[@]}" =~ "What is your user email? {[email protected]}: " ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global user.email [email protected]" ]] | ||
[[ "${lines[@]}" =~ "Please specify a command to start the editor. {edi}: " ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global core.editor edi" ]] | ||
} | ||
|
||
@test "'acquire-git': standards are configured as expected on Windows" { | ||
fake-pass "uname -s" Windows | ||
check git-elegant acquire-git | ||
[[ "${lines[@]}" =~ "==>> git config --global core.commentChar |" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global apply.whitespace fix" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.prune true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.pruneTags false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global core.autocrlf true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global pull.rebase true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global rebase.autoStash false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global elegant.acquired true" ]] | ||
# negative checks are used instead of checking commands size | ||
[[ ! "${lines[@]}" =~ "==>> git config --global credential.helper osxkeychain" ]] | ||
[[ ! "${lines[@]}" =~ "==>> git config --global core.autocrlf input" ]] | ||
} | ||
|
||
@test "'acquire-git': standards are configured as expected on Linux" { | ||
fake-pass "uname -s" Linux | ||
check git-elegant acquire-git | ||
[[ "${lines[@]}" =~ "==>> git config --global core.commentChar |" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global apply.whitespace fix" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.prune true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.pruneTags false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global core.autocrlf input" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global pull.rebase true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global rebase.autoStash false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global elegant.acquired true" ]] | ||
# negative checks are used instead of checking commands size | ||
[[ ! "${lines[@]}" =~ "==>> git config --global credential.helper osxkeychain" ]] | ||
[[ ! "${lines[@]}" =~ "==>> git config --global core.autocrlf true" ]] | ||
} | ||
|
||
@test "'acquire-git': standards are configured as expected on Darwin" { | ||
fake-pass "uname -s" Darwin | ||
check git-elegant acquire-git | ||
[[ "${lines[@]}" =~ "==>> git config --global core.commentChar |" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global apply.whitespace fix" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.prune true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global fetch.pruneTags false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global core.autocrlf input" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global pull.rebase true" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global rebase.autoStash false" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global credential.helper osxkeychain" ]] | ||
[[ "${lines[@]}" =~ "==>> git config --global elegant.acquired true" ]] | ||
# negative checks are used instead of checking commands size | ||
[[ ! "${lines[@]}" =~ "==>> git config --global core.autocrlf true" ]] | ||
} | ||
|
||
@test "'acquire-git': new aliases are configured as expected" { | ||
check git-elegant acquire-git | ||
for next in $(git-elegant commands); do | ||
echo "Test aliasing of '${next}' command" | ||
[[ "${lines[@]}" =~ "==>> git config --global alias.${next} elegant ${next}" ]] | ||
echo "Tested successfully!" | ||
done | ||
} | ||
|
||
@test "'acquire-git': old aliases remove correctly if they are present" { | ||
repo git config --global "alias.aaa" "\"elegant aaa\"" | ||
repo git config --global "alias.bbb" "\"elegant bbb\"" | ||
check git-elegant acquire-git | ||
[[ "$status" -eq 0 ]] | ||
[[ "${lines[@]}" =~ "2 Elegant Git aliases were removed." ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,20 @@ teardown() { | |
[[ "$status" -eq 0 ]] | ||
[[ "${lines[@]}" =~ "2 Elegant Git aliases were removed." ]] | ||
} | ||
|
||
@test "'acquire-repository': 'elegant.acquired' affects configuration correctly" { | ||
fake-pass "uname -s" Linux | ||
repo git config --local "alias.aaa" "\"elegant aaa\"" | ||
repo git config --global "alias.bbb" "\"elegant bbb\"" | ||
repo git config --global "elegant.acquired" "true" | ||
check git-elegant acquire-repository | ||
[[ "${lines[@]}" =~ "What is your user name? {Elegant Git}: " ]] | ||
[[ "${lines[@]}" =~ "==>> git config --local user.name Elegant Git" ]] | ||
[[ "${lines[@]}" =~ "What is your user email? {[email protected]}: " ]] | ||
[[ "${lines[@]}" =~ "==>> git config --local user.email [email protected]" ]] | ||
[[ ! "${lines[@]}" =~ "Please specify a command to start the editor. {edi}: " ]] | ||
[[ ! "${lines[@]}" =~ "==>> git config --local core.editor edi" ]] | ||
[[ ! "${lines[@]}" =~ "==>> git config --local core.commentChar |" ]] | ||
[[ "${lines[@]}" =~ "1 Elegant Git aliases were removed." ]] | ||
[[ ! "${lines[@]}" =~ "==>> git config --local alias.acquire-repository elegant acquire-repository" ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters