-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issues around Git remote fetching
Leverage the standard Git command for such operations, which should anyways be available for using the GitHub CLI. There are few issues like [1] with SSH known hosts when using go-git. [1] go-git/go-git#411
- Loading branch information
Showing
7 changed files
with
48 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cli | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"github.com/cli/safeexec" | ||
"os" | ||
"os/exec" | ||
) | ||
|
||
// RunCommandInDir runs any command in the specified working directory | ||
func RunCommandInDir(executable string, workingDir string, env []string, args ...string) (stdOut, stdErr bytes.Buffer, err error) { | ||
executablePath, err := safeexec.LookPath(executable) | ||
if err != nil { | ||
err = fmt.Errorf("error while looking up the command specified: %s: %w", executablePath, err) | ||
return | ||
} | ||
cmd := exec.Command(executablePath, args...) | ||
cmd.Dir = workingDir | ||
cmd.Stdout = &stdOut | ||
cmd.Stderr = &stdErr | ||
if env != nil { | ||
cmd.Env = env | ||
} | ||
err = cmd.Run() | ||
fmt.Print(stdOut.String()) | ||
_, _ = fmt.Fprint(os.Stderr, stdErr.String()) | ||
if err != nil { | ||
err = fmt.Errorf("failed to run command: %s. error: %w", stdErr.String(), err) | ||
return | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters