Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Support GitHub Pull Request refspec #1658

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 15 additions & 4 deletions gps/vcs_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func newVcsLocalErrorOr(err error, args []string, out, msg string) error {
return vcs.NewLocalError(msg, errors.Wrapf(err, "command failed: %v", args), out)
}

const envGitRefspecs = "DEP_GIT_REFSPECS"

func (r *gitRepo) get(ctx context.Context) error {
cmd := commandContext(
ctx,
Expand All @@ -99,17 +101,26 @@ func (r *gitRepo) get(ctx context.Context) error {
"unable to get repository")
}

// If there are additional refspecs defined then make sure they are fetched
// after the initial clone operation.
if os.Getenv(envGitRefspecs) != "" {
return r.fetch(ctx)
}

return nil
}

func (r *gitRepo) fetch(ctx context.Context) error {
cmd := commandContext(
ctx,
"git",
"fetch",
"--tags",
"--prune",
r.RemoteLocation,
append([]string{
"fetch",
"--tags",
"--prune",
r.RemoteLocation,
},
strings.Split(os.Getenv(envGitRefspecs), ",")...)...,
)
cmd.SetDir(r.LocalPath())
// Ensure no prompting for PWs
Expand Down