mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 18:31:00 +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_PULL_REQUEST", "123")
|
||||
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 checkout -qf -b pr/123 origin/pr/123")
|
||||
|
||||
|
|
|
@ -103,22 +103,19 @@ func (r *Repo) Commands() []string {
|
|||
}
|
||||
|
||||
cmds := []string{}
|
||||
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive --branch=%s %s %s", r.Depth, branch, r.Path, r.Dir))
|
||||
|
||||
switch {
|
||||
// if a specific commit is provided then we'll
|
||||
// need to clone it.
|
||||
case len(r.PR) > 0:
|
||||
|
||||
if len(r.PR) > 0 {
|
||||
// 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 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 fetch origin +refs/pull/%s/merge:", r.PR))
|
||||
//cmds = append(cmds, fmt.Sprintf("git checkout -qf %s", "FETCH_HEAD"))
|
||||
// if a specific commit is provided then we'll
|
||||
// need to clone it.
|
||||
case len(r.Commit) > 0:
|
||||
} else {
|
||||
// Otherwise just clone the branch.
|
||||
cmds = append(cmds, fmt.Sprintf("git clone --depth=%d --recursive --branch=%s %s %s", r.Depth, branch, r.Path, r.Dir))
|
||||
// If a specific commit is provided then we'll need to check it out.
|
||||
if len(r.Commit) > 0 {
|
||||
cmds = append(cmds, fmt.Sprintf("git checkout -qf %s", r.Commit))
|
||||
}
|
||||
}
|
||||
|
||||
return cmds
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue