Compare commits
1
Commits
5d7dee3305
...
fc006a6bcb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fc006a6bcb |
No files matched your search
@@ -360,7 +360,9 @@ func (c *workerConfig) openPR(dir string, job *builderJob, res *buildResult) (st
|
|||||||
if len(short) > 8 {
|
if len(short) > 8 {
|
||||||
short = short[:8]
|
short = short[:8]
|
||||||
}
|
}
|
||||||
branch := "draft/" + res.GameID + "-" + short
|
// One branch per run: a rerun of the same job must not push onto the earlier run's branch, which
|
||||||
|
// may have gained review commits since
|
||||||
|
branch := draftBranch(res.GameID, short, time.Now())
|
||||||
auth := "http.extraHeader=Authorization: token " + c.botToken
|
auth := "http.extraHeader=Authorization: token " + c.botToken
|
||||||
steps := []struct {
|
steps := []struct {
|
||||||
name string
|
name string
|
||||||
@@ -415,3 +417,7 @@ func readJSON(p string, out any) error {
|
|||||||
}
|
}
|
||||||
return json.Unmarshal(raw, out)
|
return json.Unmarshal(raw, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func draftBranch(gameID, job string, at time.Time) string {
|
||||||
|
return "draft/" + gameID + "-" + job + "-" + at.UTC().Format("20060102-150405")
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCheckBotNeedsPushAccess(t *testing.T) {
|
func TestCheckBotNeedsPushAccess(t *testing.T) {
|
||||||
@@ -68,3 +69,11 @@ func TestCheckBotWithRepositoryOnlyToken(t *testing.T) {
|
|||||||
t.Errorf("identity = %s <%s>", c.botLogin, c.botEmail)
|
t.Errorf("identity = %s <%s>", c.botLogin, c.botEmail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDraftBranchIsNewForEveryRun(t *testing.T) {
|
||||||
|
first := draftBranch("example", "4b174b2d", time.Date(2026, 10, 25, 21, 30, 0, 0, time.UTC))
|
||||||
|
rerun := draftBranch("example", "4b174b2d", time.Date(2026, 10, 25, 22, 5, 9, 0, time.UTC))
|
||||||
|
if first != "draft/example-4b174b2d-20261025-213000" || first == rerun {
|
||||||
|
t.Errorf("first %q, rerun %q", first, rerun)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user