UseDefaultTag for skip build if not default branch.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-11-09 13:24:35 +08:00
parent c591da7e86
commit 5fa26ebb5f
5 changed files with 82 additions and 79 deletions

View File

@@ -61,6 +61,24 @@ type (
}
)
func stripHeadPrefix(ref string) string {
ref = strings.TrimPrefix(ref, "refs/heads/")
return ref
}
// UseDefaultTag for keep only default branch for latest tag
func UseDefaultTag(ref, defaultBranch string) bool {
if strings.HasPrefix(ref, "refs/tags/") {
return true
}
if stripHeadPrefix(ref) == defaultBranch {
return true
}
return false
}
// Exec executes the plugin step
func (p Plugin) Exec() error {
// start the Docker daemon server