aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-07-27 00:14:01 +0200
committerMichael Muré <batolettre@gmail.com>2020-09-29 20:42:21 +0200
commitb127481364176ac7ecb56c1604e1460251574859 (patch)
tree389e4f4596183c009ed53a078ad93bc72d6c4564 /repository/git.go
parentd171e11028f5993137a5f83beb7fe002bed866f5 (diff)
downloadgit-bug-b127481364176ac7ecb56c1604e1460251574859.tar.gz
repository: add access to the system keyring, with fallback on a file
Diffstat (limited to 'repository/git.go')
-rw-r--r--repository/git.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/repository/git.go b/repository/git.go
index 3d756324..85107ba5 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -26,6 +26,8 @@ type GitRepo struct {
clocksMutex sync.Mutex
clocks map[string]lamport.Clock
+
+ keyring Keyring
}
// LocalConfig give access to the repository scoped configuration
@@ -38,6 +40,10 @@ func (repo *GitRepo) GlobalConfig() Config {
return newGitConfig(repo, true)
}
+func (repo *GitRepo) Keyring() Keyring {
+ return repo.keyring
+}
+
// Run the given git command with the given I/O reader/writers, returning an error if it fails.
func (repo *GitRepo) runGitCommandWithIO(stdin io.Reader, stdout, stderr io.Writer, args ...string) error {
// make sure that the working directory for the command
@@ -83,9 +89,15 @@ func (repo *GitRepo) runGitCommand(args ...string) (string, error) {
// NewGitRepo determines if the given working directory is inside of a git repository,
// and returns the corresponding GitRepo instance if it is.
func NewGitRepo(path string, clockLoaders []ClockLoader) (*GitRepo, error) {
+ k, err := defaultKeyring()
+ if err != nil {
+ return nil, err
+ }
+
repo := &GitRepo{
- path: path,
- clocks: make(map[string]lamport.Clock),
+ path: path,
+ clocks: make(map[string]lamport.Clock),
+ keyring: k,
}
// Check the repo and retrieve the root path