aboutsummaryrefslogtreecommitdiffstats
path: root/repository/git.go
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/git.go
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/git.go')
-rw-r--r--repository/git.go12
1 files changed, 6 insertions, 6 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)