-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support management of global and system level git config (#91)
- Loading branch information
1 parent
21aec48
commit 0d00716
Showing
7 changed files
with
112 additions
and
100 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -23,7 +23,6 @@ SOFTWARE. | |
package git_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
git "github.com/purpleclay/gitz" | ||
|
@@ -34,26 +33,30 @@ import ( | |
|
||
func TestConfig(t *testing.T) { | ||
gittest.InitRepository(t) | ||
setConfig(t, "user.name", "joker") | ||
gittest.ConfigSet(t, "user.name", "joker", "user.email", "[email protected]") | ||
|
||
client, _ := git.NewClient() | ||
cfg, err := client.Config("user.name") | ||
cfg, err := client.Config() | ||
|
||
require.NoError(t, err) | ||
require.Len(t, cfg, 2) | ||
assert.Equal(t, "joker", cfg[0]) | ||
assert.Equal(t, gittest.DefaultAuthorName, cfg[1]) | ||
assert.Equal(t, "joker", cfg["user.name"]) | ||
assert.Equal(t, "[email protected]", cfg["user.email"]) | ||
} | ||
|
||
func setConfig(t *testing.T, path, value string) { | ||
t.Helper() | ||
_, err := gittest.Exec(t, fmt.Sprintf("git config --add %s '%s'", path, value)) | ||
func TestConfigOnlyLatestValues(t *testing.T) { | ||
gittest.InitRepository(t) | ||
gittest.ConfigSet(t, "user.name", "joker", "user.name", "scarecrow") | ||
|
||
client, _ := git.NewClient() | ||
cfg, err := client.Config() | ||
|
||
require.NoError(t, err) | ||
assert.Equal(t, "scarecrow", cfg["user.name"]) | ||
} | ||
|
||
func TestConfigL(t *testing.T) { | ||
gittest.InitRepository(t) | ||
setConfig(t, "user.name", "alfred") | ||
gittest.ConfigSet(t, "user.name", "alfred") | ||
|
||
client, _ := git.NewClient() | ||
cfg, err := client.ConfigL("user.name", "user.email") | ||
|
@@ -67,16 +70,6 @@ func TestConfigL(t *testing.T) { | |
assert.Equal(t, gittest.DefaultAuthorEmail, cfg["user.email"][0]) | ||
} | ||
|
||
func TestConfigSet(t *testing.T) { | ||
gittest.InitRepository(t) | ||
|
||
client, _ := git.NewClient() | ||
err := client.ConfigSet("user.age", "unknown") | ||
|
||
require.NoError(t, err) | ||
configEquals(t, "user.age", "unknown") | ||
} | ||
|
||
func configEquals(t *testing.T, path, expected string) { | ||
t.Helper() | ||
cfg, err := gittest.Exec(t, "git config --get "+path) | ||
|
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