From bc5199cc1f9c480d9bfcac7cd7c8c9145cccf9cf Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 16 Nov 2022 17:28:37 -0500 Subject: [PATCH] feat(server): use git-module for git server commands --- server/git/ssh.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/server/git/ssh.go b/server/git/ssh.go index 6aa5f83de3f5e9ae00efc76588d7586a24d9cb58..b3165b7e4c1f24c0bdf1307c309ea4f5a9b455e3 100644 --- a/server/git/ssh.go +++ b/server/git/ssh.go @@ -5,13 +5,13 @@ import ( "fmt" "log" "os" - "os/exec" "path/filepath" "strings" "github.com/charmbracelet/soft-serve/git" "github.com/charmbracelet/wish" "github.com/gliderlabs/ssh" + g "github.com/gogs/git-module" ) // ErrNotAuthed represents unauthorized access. @@ -215,14 +215,12 @@ func ensureRepo(dir string, repo string) error { } func runGit(s ssh.Session, dir string, args ...string) error { - usi := exec.CommandContext(s.Context(), "git", args...) - usi.Dir = dir - usi.Stdout = s - usi.Stdin = s - if err := usi.Run(); err != nil { - return err - } - return nil + c := g.NewCommand(args...) + return c.RunInDirWithOptions(dir, g.RunInDirOptions{ + Stdout: s, + Stdin: s, + Stderr: s.Stderr(), + }) } func ensureDefaultBranch(s ssh.Session, repoPath string) error {