Skip to content
This repository was archived by the owner on May 19, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pipeline:
image: plugins/docker:17.05
pull: true
repo: plugins/git
tags: [ latest, 1.4.0, 1.4, 1 ]
tags: [ latest, 1.3.0, 1.3, 1 ]
secrets: [ docker_username, docker_password ]
dockerfile: Dockerfile
when:
Expand Down
6 changes: 3 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func (p Plugin) Exec() error {
cmds = append(cmds, remote(p.Repo.Clone))
}

cmds = append(cmds, fetch(p.Build.Ref, p.Config.Tags, p.Config.Depth))

switch {
case isTag(p.Build.Event, p.Build.Ref):
case isPullRequest(p.Build.Event) || isTag(p.Build.Event, p.Build.Ref):
cmds = append(cmds, fetch(p.Build.Ref, p.Config.Tags, p.Config.Depth))
cmds = append(cmds, checkoutHead())
default:
cmds = append(cmds, fetch(p.Build.Ref, p.Config.Tags, p.Config.Depth))
cmds = append(cmds, checkoutSha(p.Build.Commit))
}

Expand Down
2 changes: 1 addition & 1 deletion plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var commits = []struct {
clone: "https://github.com/octocat/Hello-World.git",
event: "pull_request",
branch: "master",
commit: "43617d6cc59d91c7d99909042c19ff122e2597fb",
commit: "553c2077f0edc3d5dc5d17262f6aa498e69d6f8e",
ref: "refs/pull/208/merge",
file: "README",
data: "Goodbye World!\n",
Expand Down
5 changes: 5 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func isDirEmpty(dir string) bool {
return err == io.EOF
}

// helper function returns true if the commit is a pull_request.
func isPullRequest(event string) bool {
return event == "pull_request"
}

// helper function returns true if the commit is a tag.
func isTag(event, ref string) bool {
return event == "tag" ||
Expand Down