aboutsummaryrefslogtreecommitdiffstats
path: root/repository
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
commit17e2ec8f5679c1ba7ae2ea45290e9303beb3c227 (patch)
treec8862ebf6e9e9314361120127bf3fc59877c3e02 /repository
parente1f597639bfc2f796f74afa87e41581087f0b26e (diff)
downloadgit-bug-17e2ec8f5679c1ba7ae2ea45290e9303beb3c227.tar.gz
bug: refactor to limit abstraction leak and to have a more reusable code for the UIs
Diffstat (limited to 'repository')
-rw-r--r--repository/git.go12
-rw-r--r--repository/mock_repo.go4
-rw-r--r--repository/repo.go4
3 files changed, 10 insertions, 10 deletions
diff --git a/repository/git.go b/repository/git.go
index 8d265325..648f56c1 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -19,6 +19,8 @@ type GitRepo struct {
// 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 {
+ fmt.Println("Running git", strings.Join(args, " "))
+
cmd := exec.Command("git", args...)
cmd.Dir = repo.Path
cmd.Stdin = stdin
@@ -99,10 +101,8 @@ func (repo *GitRepo) GetCoreEditor() (string, error) {
}
// FetchRefs fetch git refs from a remote
-func (repo *GitRepo) FetchRefs(remote, refPattern, remoteRefPattern string) error {
- remoteRefSpec := fmt.Sprintf(remoteRefPattern, remote)
- fetchRefSpec := fmt.Sprintf("%s:%s", refPattern, remoteRefSpec)
- err := repo.runGitCommandInline("fetch", remote, fetchRefSpec)
+func (repo *GitRepo) FetchRefs(remote, refSpec string) error {
+ err := repo.runGitCommandInline("fetch", remote, "\""+refSpec+"\"")
if err != nil {
return fmt.Errorf("failed to fetch from the remote '%s': %v", remote, err)
@@ -112,8 +112,8 @@ func (repo *GitRepo) FetchRefs(remote, refPattern, remoteRefPattern string) erro
}
// PushRefs push git refs to a remote
-func (repo *GitRepo) PushRefs(remote string, refPattern string) error {
- err := repo.runGitCommandInline("push", remote, refPattern)
+func (repo *GitRepo) PushRefs(remote string, refSpec string) error {
+ err := repo.runGitCommandInline("push", remote, refSpec)
if err != nil {
return fmt.Errorf("failed to push to the remote '%s': %v", remote, err)
diff --git a/repository/mock_repo.go b/repository/mock_repo.go
index c5ac53a4..4bd25738 100644
--- a/repository/mock_repo.go
+++ b/repository/mock_repo.go
@@ -48,11 +48,11 @@ func (r *mockRepoForTest) GetCoreEditor() (string, error) {
}
// PushRefs push git refs to a remote
-func (r *mockRepoForTest) PushRefs(remote string, refPattern string) error {
+func (r *mockRepoForTest) PushRefs(remote string, refSpec string) error {
return nil
}
-func (r *mockRepoForTest) FetchRefs(remote string, refPattern string, remoteRefPattern string) error {
+func (r *mockRepoForTest) FetchRefs(remote string, refSpec string) error {
return nil
}
diff --git a/repository/repo.go b/repository/repo.go
index 7ba8a8b5..6ab7be91 100644
--- a/repository/repo.go
+++ b/repository/repo.go
@@ -22,10 +22,10 @@ type Repo interface {
GetCoreEditor() (string, error)
// FetchRefs fetch git refs from a remote
- FetchRefs(remote string, refPattern string, remoteRefPattern string) error
+ FetchRefs(remote string, refSpec string) error
// PushRefs push git refs to a remote
- PushRefs(remote string, refPattern string) error
+ PushRefs(remote string, refSpec string) error
// StoreData will store arbitrary data and return the corresponding hash
StoreData(data []byte) (util.Hash, error)