mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 18:31:00 +00:00
Merge pull request #1237 from pheuter/patch-1
When cloning pull requests, use specific branch
This commit is contained in:
commit
f23037457b
2 changed files with 2 additions and 2 deletions
|
@ -594,7 +594,7 @@ func TestWriteBuildScript(t *testing.T) {
|
||||||
f.WriteEnv("CI_PULL_REQUEST", "123")
|
f.WriteEnv("CI_PULL_REQUEST", "123")
|
||||||
f.WriteHost("127.0.0.1")
|
f.WriteHost("127.0.0.1")
|
||||||
f.WriteFile("$HOME/.ssh/id_rsa", []byte("ssh-rsa AAA..."), 600)
|
f.WriteFile("$HOME/.ssh/id_rsa", []byte("ssh-rsa AAA..."), 600)
|
||||||
f.WriteCmd("git clone --depth=0 --recursive git://github.com/drone/drone.git /var/cache/drone/github.com/drone/drone")
|
f.WriteCmd("git clone --depth=0 --recursive --branch=master git://github.com/drone/drone.git /var/cache/drone/github.com/drone/drone")
|
||||||
f.WriteCmd("git fetch origin +refs/pull/123/head:refs/remotes/origin/pr/123")
|
f.WriteCmd("git fetch origin +refs/pull/123/head:refs/remotes/origin/pr/123")
|
||||||
f.WriteCmd("git checkout -qf -b pr/123 origin/pr/123")
|
f.WriteCmd("git checkout -qf -b pr/123 origin/pr/123")
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (r *Repo) Commands() []string {
|
||||||
cmds := []string{}
|
cmds := []string{}
|
||||||
if len(r.PR) > 0 {
|
if len(r.PR) > 0 {
|
||||||
// If a specific PR is provided then we need to clone it.
|
// If a specific PR is provided then we need to clone it.
|
||||||
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive %s %s", r.Depth, r.Path, r.Dir))
|
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive --branch=%s %s %s", r.Depth, branch, r.Path, r.Dir))
|
||||||
cmds = append(cmds, fmt.Sprintf("git fetch origin +refs/pull/%s/head:refs/remotes/origin/pr/%s", r.PR, r.PR))
|
cmds = append(cmds, fmt.Sprintf("git fetch origin +refs/pull/%s/head:refs/remotes/origin/pr/%s", r.PR, r.PR))
|
||||||
cmds = append(cmds, fmt.Sprintf("git checkout -qf -b pr/%s origin/pr/%s", r.PR, r.PR))
|
cmds = append(cmds, fmt.Sprintf("git checkout -qf -b pr/%s origin/pr/%s", r.PR, r.PR))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue