diff options
author | Michael Muré <batolettre@gmail.com> | 2020-07-28 12:56:46 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-09-29 20:42:21 +0200 |
commit | 3ecbf8db28105d147340b80d65a5a6d537233135 (patch) | |
tree | 9bda351f7d1d520fa0ae51b155792ffca3517a9d /repository | |
parent | b127481364176ac7ecb56c1604e1460251574859 (diff) | |
download | git-bug-3ecbf8db28105d147340b80d65a5a6d537233135.tar.gz |
bridge: store credentials in the Keyring instead of the git config
Diffstat (limited to 'repository')
-rw-r--r-- | repository/git_testing.go | 18 | ||||
-rw-r--r-- | repository/repo.go | 5 |
2 files changed, 17 insertions, 6 deletions
diff --git a/repository/git_testing.go b/repository/git_testing.go index 5ae4ccc9..7d40bf1f 100644 --- a/repository/git_testing.go +++ b/repository/git_testing.go @@ -3,6 +3,8 @@ package repository import ( "io/ioutil" "log" + + "github.com/99designs/keyring" ) // This is intended for testing only @@ -34,7 +36,11 @@ func CreateTestRepo(bare bool) TestedRepo { log.Fatal("failed to set user.email for test repository: ", err) } - return repo + // make sure we use a mock keyring for testing to not interact with the global system + return &replaceKeyring{ + TestedRepo: repo, + keyring: keyring.NewArrayKeyring(nil), + } } func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) { @@ -56,3 +62,13 @@ func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) { return repoA, repoB, remote } + +// replaceKeyring allow to replace the Keyring of the underlying repo +type replaceKeyring struct { + TestedRepo + keyring Keyring +} + +func (rk replaceKeyring) Keyring() Keyring { + return rk.keyring +} diff --git a/repository/repo.go b/repository/repo.go index 696b032e..7a69a14f 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -20,11 +20,6 @@ var ( type RepoConfig interface { // LocalConfig give access to the repository scoped configuration LocalConfig() Config - - // GlobalConfig give access to the git global configuration - // Deprecated: to remove in favor of Keyring() - // TODO: remove - GlobalConfig() Config } // RepoKeyring give access to a user-wide storage for secrets |