mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-19 16:31:01 +00:00
Merge pull request #469 from aluzzardi/b-284
Fix #284: Do not checkout the branch if a commit or PR is specified.
This commit is contained in:
commit
996d6e8c73
2 changed files with 11 additions and 14 deletions
|
@ -568,7 +568,7 @@ func TestWriteBuildScript(t *testing.T) {
|
||||||
f.WriteEnv("CI_BRANCH", "master")
|
f.WriteEnv("CI_BRANCH", "master")
|
||||||
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.WriteCmd("git clone --depth=0 --recursive --branch=master git://github.com/drone/drone.git /var/cache/drone/github.com/drone/drone")
|
f.WriteCmd("git clone --depth=0 --recursive 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")
|
||||||
|
|
||||||
|
|
|
@ -103,21 +103,18 @@ func (r *Repo) Commands() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds := []string{}
|
cmds := []string{}
|
||||||
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive --branch=%s %s %s", r.Depth, branch, r.Path, r.Dir))
|
if len(r.PR) > 0 {
|
||||||
|
// If a specific PR is provided then we need to clone it.
|
||||||
switch {
|
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive %s %s", r.Depth, r.Path, r.Dir))
|
||||||
// if a specific commit is provided then we'll
|
|
||||||
// need to clone it.
|
|
||||||
case len(r.PR) > 0:
|
|
||||||
|
|
||||||
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))
|
||||||
//cmds = append(cmds, fmt.Sprintf("git fetch origin +refs/pull/%s/merge:", r.PR))
|
} else {
|
||||||
//cmds = append(cmds, fmt.Sprintf("git checkout -qf %s", "FETCH_HEAD"))
|
// Otherwise just clone the branch.
|
||||||
// if a specific commit is provided then we'll
|
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive --branch=%s %s %s", r.Depth, branch, r.Path, r.Dir))
|
||||||
// need to clone it.
|
// If a specific commit is provided then we'll need to check it out.
|
||||||
case len(r.Commit) > 0:
|
if len(r.Commit) > 0 {
|
||||||
cmds = append(cmds, fmt.Sprintf("git checkout -qf %s", r.Commit))
|
cmds = append(cmds, fmt.Sprintf("git checkout -qf %s", r.Commit))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmds
|
return cmds
|
||||||
|
|
Loading…
Reference in a new issue