Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions git.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package getit

import (
"bytes"
"context"
"fmt"
"net/url"
"os/exec"
"strings"

"github.com/kballard/go-shellquote"
)

// The Git [Resolver] uses Git repositories as archive sources, cloning directly.
Expand Down Expand Up @@ -43,11 +44,10 @@ func (g *Git) Fetch(ctx context.Context, source Source, dest string) error {
repoURL := convertGitURL(source.URL)
args = append(args, repoURL, dest)

stderr := &bytes.Buffer{}
cmd := exec.CommandContext(ctx, "git", args...)
cmd.Stderr = stderr
if err := cmd.Run(); err != nil {
return fmt.Errorf("git clone failed: %w: %s", err, stderr)
if output, err := cmd.CombinedOutput(); err != nil {
argsStr := shellquote.Join(args...)
return fmt.Errorf("git clone failed: git %s: %w: %s", argsStr, err, output)
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ require github.com/alecthomas/assert/v2 v2.11.0
require (
github.com/alecthomas/repr v0.4.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=