diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-12 12:44:46 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-12 12:44:46 +0200 |
commit | c498674718608a1171a4fcef6f26184df7d5fa7b (patch) | |
tree | 9cc53ea07b61d52b12cd5fa3367b25d04bebc150 /repository | |
parent | d0443659123f912e9385e27efebe4b7da65aa2f6 (diff) | |
download | git-bug-c498674718608a1171a4fcef6f26184df7d5fa7b.tar.gz |
add the new bug command with a very primitive bug datastructure
Diffstat (limited to 'repository')
-rw-r--r-- | repository/git.go | 30 | ||||
-rw-r--r-- | repository/mock_repo.go | 4 | ||||
-rw-r--r-- | repository/repo.go | 3 |
3 files changed, 20 insertions, 17 deletions
diff --git a/repository/git.go b/repository/git.go index 8e957523..309641f6 100644 --- a/repository/git.go +++ b/repository/git.go @@ -78,6 +78,11 @@ func (repo *GitRepo) GetRepoStateHash() (string, error) { return fmt.Sprintf("%x", sha1.Sum([]byte(stateSummary))), err } +// GetUserName returns the name the the user has used to configure git +func (repo *GitRepo) GetUserName() (string, error) { + return repo.runGitCommand("config", "user.name") +} + // GetUserEmail returns the email address that the user has used to configure git. func (repo *GitRepo) GetUserEmail() (string, error) { return repo.runGitCommand("config", "user.email") @@ -88,30 +93,25 @@ func (repo *GitRepo) GetCoreEditor() (string, error) { return repo.runGitCommand("var", "GIT_EDITOR") } - // PullRefs pull git refs from a remote func (repo *GitRepo) PullRefs(remote string, refPattern string) error { - refspec := fmt.Sprintf("%s:%s", refPattern, refPattern) + fetchRefSpec := fmt.Sprintf("+%s:%s", refPattern, refPattern) + err := repo.runGitCommandInline("fetch", remote, fetchRefSpec) - // The push is liable to fail if the user forgot to do a pull first, so - // we treat errors as user errors rather than fatal errors. - err := repo.runGitCommandInline("push", remote, refspec) - if err != nil { - return fmt.Errorf("failed to push to the remote '%s': %v", remote, err) - } - return nil + // TODO: merge new data + + return err } // PushRefs push git refs to a remote func (repo *GitRepo) PushRefs(remote string, refPattern string) error { - remoteNotesRefPattern := getRemoteNotesRef(remote, refPattern) - fetchRefSpec := fmt.Sprintf("+%s:%s", refPattern, remoteNotesRefPattern) - err := repo.runGitCommandInline("fetch", remote, fetchRefSpec) + // The push is liable to fail if the user forgot to do a pull first, so + // we treat errors as user errors rather than fatal errors. + err := repo.runGitCommandInline("push", remote, refPattern) if err != nil { - return err + return fmt.Errorf("failed to push to the remote '%s': %v", remote, err) } - - return repo.mergeRemoteNotes(remote, notesRefPattern) + return nil } /* diff --git a/repository/mock_repo.go b/repository/mock_repo.go index 8587d0da..f5d27d12 100644 --- a/repository/mock_repo.go +++ b/repository/mock_repo.go @@ -7,7 +7,7 @@ import ( ) // mockRepoForTest defines an instance of Repo that can be used for testing. -type mockRepoForTest struct {} +type mockRepoForTest struct{} // GetPath returns the path to the repo. func (r *mockRepoForTest) GetPath() string { return "~/mockRepo/" } @@ -30,4 +30,4 @@ func (r *mockRepoForTest) GetCoreEditor() (string, error) { return "vi", nil } // PushRefs push git refs to a remote func (r *mockRepoForTest) PushRefs(remote string, refPattern string) error { return nil -}
\ No newline at end of file +} diff --git a/repository/repo.go b/repository/repo.go index 7329f183..11bb132e 100644 --- a/repository/repo.go +++ b/repository/repo.go @@ -6,6 +6,9 @@ type Repo interface { // GetPath returns the path to the repo. GetPath() string + // GetUserName returns the name the the user has used to configure git + GetUserName() (string, error) + // GetUserEmail returns the email address that the user has used to configure git. GetUserEmail() (string, error) |