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

Commit ea1ce3a

Browse files
committed
Support GitHub Pull Request refspec
This patch introduces support for settings a dep constraint's revision to a commit that exists in a GitHub pull request. Issue #1583 outlines how GitHub PRs use a non-standard Git refspec, `+refs/pull/PR_ID`, to store the commit built by CI systems such as Travis-CI. This patch includes a new refspec when Git's VCS handler performs a fetch operation. The refspec `+refs/pull/*:refs/pull/%x/*` is used where `%x` is an MD5 hash of the constraint's configured remote location. This ensures that if the remote location is changed, the refspec will point to a new location locally. This unblocks build failures occurring in rexray/gocsi#71 and rexray/gocsi#80. cc @sbezverk @sdboyer
1 parent d81b4d0 commit ea1ce3a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

gps/vcs_repo.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package gps
66

77
import (
88
"context"
9+
"crypto/md5"
910
"encoding/xml"
1011
"fmt"
1112
"os"
@@ -103,13 +104,20 @@ func (r *gitRepo) get(ctx context.Context) error {
103104
}
104105

105106
func (r *gitRepo) fetch(ctx context.Context) error {
107+
108+
// Hash the remote location to generate the name
109+
// of the local refs/pulls namespace.
110+
h := md5.New()
111+
h.Write([]byte(r.RemoteLocation))
112+
106113
cmd := commandContext(
107114
ctx,
108115
"git",
109116
"fetch",
110117
"--tags",
111118
"--prune",
112119
r.RemoteLocation,
120+
fmt.Sprintf("+refs/pull/*:refs/pull/%x/*", h.Sum(nil)),
113121
)
114122
cmd.SetDir(r.LocalPath())
115123
// Ensure no prompting for PWs

0 commit comments

Comments
 (0)