fix(ops/besadii): Do not trigger builds for deleted branches
This commit is contained in:
parent
28560fcf8a
commit
a2bb8a7e1d
1 changed files with 12 additions and 7 deletions
|
@ -22,6 +22,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var gitBin = "git"
|
var gitBin = "git"
|
||||||
|
var branchPrefix = "refs/heads/"
|
||||||
|
|
||||||
|
// This value is set by the git hook invocation when a branch is
|
||||||
|
// removed, builds should not be triggered in that case.
|
||||||
|
var deletedBranch = "0000000000000000000000000000000000000000"
|
||||||
|
|
||||||
// Represents an updated reference as passed to besadii by git
|
// Represents an updated reference as passed to besadii by git
|
||||||
//
|
//
|
||||||
|
@ -143,15 +148,15 @@ func parseRefUpdates() ([]refUpdate, error) {
|
||||||
return nil, fmt.Errorf("invalid ref update: '%s'", line)
|
return nil, fmt.Errorf("invalid ref update: '%s'", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(fragments[2], "refs/heads/") {
|
update := refUpdate{
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
updates = append(updates, refUpdate{
|
|
||||||
old: fragments[0],
|
old: fragments[0],
|
||||||
new: fragments[1],
|
new: fragments[1],
|
||||||
name: strings.TrimPrefix(fragments[2], "refs/heads/"),
|
name: strings.TrimPrefix(fragments[2], branchPrefix),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(update.name, branchPrefix) && update.new != deletedBranch {
|
||||||
|
updates = append(updates, update)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scanner.Err(); err != nil {
|
if err := scanner.Err(); err != nil {
|
||||||
|
|
Loading…
Reference in a new issue