diff --git a/api/lock_api.go b/api/lock_api.go index 7dd2df55..345f63f2 100644 --- a/api/lock_api.go +++ b/api/lock_api.go @@ -4,8 +4,6 @@ import ( "fmt" "strconv" "time" - - "github.com/git-lfs/git-lfs/config" ) // LockService is an API service which encapsulates the Git LFS Locking API. @@ -144,15 +142,8 @@ type Committer struct { Email string `json:"email"` } -// CurrentCommitter returns a Committer instance populated with the same -// credentials as would be used to author a commit. In particular, the -// "user.name" and "user.email" configuration values are used from the -// config.Config singleton. -func CurrentCommitter() Committer { - name, _ := config.Config.Git.Get("user.name") - email, _ := config.Config.Git.Get("user.email") - - return Committer{name, email} +func NewCommitter(name, email string) Committer { + return Committer{Name: name, Email: email} } // LockRequest encapsulates the payload sent across the API when a client would diff --git a/config/config.go b/config/config.go index b4e23f17..756d2fab 100644 --- a/config/config.go +++ b/config/config.go @@ -492,3 +492,12 @@ func (c *Configuration) loadGitConfig() bool { return false } + +// CurrentCommitter returns the name/email that would be used to author a commit +// with this configuration. In particular, the "user.name" and "user.email" +// configuration values are used +func (c *Configuration) CurrentCommitter() (name, email string) { + name, _ = c.Git.Get("user.name") + email, _ = c.Git.Get("user.email") + return +} diff --git a/locking/locks.go b/locking/locks.go index 122c281f..ddbb52d2 100644 --- a/locking/locks.go +++ b/locking/locks.go @@ -57,7 +57,7 @@ func (c *Client) LockFile(path string) (id string, e error) { s, resp := c.apiClient.Locks.Lock(&api.LockRequest{ Path: path, - Committer: api.CurrentCommitter(), + Committer: api.NewCommitter(c.cfg.CurrentCommitter()), LatestRemoteCommit: latest.Sha, })