Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2017-09-15 21:47:50 +0300
committerAhmad Sherif <me@ahmadsherif.com>2017-09-20 13:50:39 +0300
commitf5b7feea6012cb9505b919042f3e2c9ae58bf6d8 (patch)
treef104d08191ec679086f9381b92889652cee97e61 /internal/git/command.go
parentfe7bfb4a1b6f3326b0051fe621c4d48468f71e91 (diff)
Refactor git command creation
Diffstat (limited to 'internal/git/command.go')
-rw-r--r--internal/git/command.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/internal/git/command.go b/internal/git/command.go
new file mode 100644
index 000000000..b219bf41b
--- /dev/null
+++ b/internal/git/command.go
@@ -0,0 +1,22 @@
+package git
+
+import (
+ "context"
+ "os/exec"
+
+ "gitlab.com/gitlab-org/gitaly/internal/command"
+ "gitlab.com/gitlab-org/gitaly/internal/helper"
+
+ pb "gitlab.com/gitlab-org/gitaly-proto/go"
+)
+
+// Command creates a git.Command with the given args
+func Command(ctx context.Context, repo *pb.Repository, args ...string) (*command.Command, error) {
+ repoPath, err := helper.GetRepoPath(repo)
+ if err != nil {
+ return nil, err
+ }
+ args = append([]string{"--git-dir", repoPath}, args...)
+
+ return command.New(ctx, exec.Command(command.GitPath(), args...), nil, nil, nil)
+}