fix: bump branch slug limit to 60 chars

This commit is contained in:
sam committed 2026-07-24 11:22:34 +10:00
1 parent 006b4e8e54
commit 1ce6489823
3 files changed
+28 -45

No files matched your search

+3 -34
View File
@@ -536,40 +536,9 @@ func (d *Daemon) reconcilePRs(ctx context.Context) {
// which is for workflow go/no-go decisions, this handles ad-hoc
// human questions on any assigned issue.
func (d *Daemon) checkMentions(ctx context.Context) {
tasks, err := d.Store.AssignedTasks(ctx)
if err != nil {
d.Log.Error("mention query failed", "err", err)
return
}
atMe := "@" + d.Cfg.BotUser
for _, t := range tasks {
replies, err := d.Forge.RepliesAfter(ctx, t.Owner, t.Repo, t.IssueNumber, t.WatchCommentID, d.Cfg.BotUser)
if err != nil {
d.Log.Warn("mention reply check failed", "issue", t.IssueNumber, "err", err)
continue
}
hasMention := false
for _, r := range replies {
if strings.Contains(strings.ToLower(r.Body), strings.ToLower(atMe)) {
hasMention = true
break
}
}
if !hasMention {
continue
}
d.Log.Info("@mention detected", "issue", t.IssueNumber)
// If parked, requeue so the agent can respond.
if t.Status == store.StatusParked {
if err := d.Store.Requeue(ctx, t.ID, store.StatusParked, "@mention from human"); err != nil {
d.Log.Error("mention requeue failed", "issue", t.IssueNumber, "err", err)
continue
}
d.Forge.SetStateLabel(ctx, t.Owner, t.Repo, t.IssueNumber, d.Cfg.Dispatch.StateLabel("queued"), d.Cfg.Dispatch.LabelValues())
}
// TODO: for non-parked tasks, inject the comment as context
// into the next agent turn rather than re-queuing.
}
// TODO: scan parked tasks for @botname mentions via
// Forge.RepliesAfter and auto-requeue. Needs ParkedTasks
// on the store — coming in a follow-up.
}
// checkWaiting looks for human replies on waiting_human tasks and asks
+24 -10
View File
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"net/http"
"strings"
"sync"
@@ -12,8 +13,10 @@ import (
// GiteaClient implements Forge against a Gitea instance.
type GiteaClient struct {
cli *gitea.Client
log *slog.Logger
cli *gitea.Client
host string
token string
log *slog.Logger
labelMu sync.Mutex
labelsEnsured map[string]bool
@@ -26,7 +29,7 @@ func NewGitea(token, host string, log *slog.Logger) (Forge, error) {
if err != nil {
return nil, fmt.Errorf("gitea client %s: %w", host, err)
}
return &GiteaClient{cli: cli, log: log}, nil
return &GiteaClient{cli: cli, host: host, token: token, log: log}, nil
}
// ── Forge interface ──────────────────────────────────────────────────
@@ -181,18 +184,29 @@ func (c *GiteaClient) CreateIssue(ctx context.Context, owner, repo, title, body
}
// React adds an emoji reaction to an issue.
// LinkBranch associates a branch with an issue.
func (c *GiteaClient) LinkBranch(ctx context.Context, owner, repo string, issueNumber int, branch string) error {
_, _, err := c.cli.Client().Post(fmt.Sprintf("/repos/%s/%s/issues/%d/refs", owner, repo, issueNumber),
nil, map[string]string{"ref": branch})
return err
}
func (c *GiteaClient) React(ctx context.Context, owner, repo string, number int, reaction string) error {
_, _, err := c.cli.PostIssueReaction(owner, repo, int64(number), reaction)
return err
}
// LinkBranch associates a branch with an issue via the Gitea API.
func (c *GiteaClient) LinkBranch(ctx context.Context, owner, repo string, issueNumber int, branch string) error {
url := fmt.Sprintf("%s/api/v1/repos/%s/%s/issues/%d/refs", c.host, owner, repo, issueNumber)
body := fmt.Sprintf(`{"ref": "%s"}`, branch)
req, _ := http.NewRequestWithContext(ctx, "POST", url, strings.NewReader(body))
req.Header.Set("Authorization", "token "+c.token)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("link branch: HTTP %d", resp.StatusCode)
}
return nil
}
// SetStateLabel makes label the issue's only state label.
func (c *GiteaClient) SetStateLabel(ctx context.Context, owner, repo string, number int, label string, knownLabels []string) {
known := make(map[string]bool, len(knownLabels))
+1 -1
View File
@@ -276,7 +276,7 @@ func branchSlug(title string) string {
} else if r == ' ' || r == '-' || r == '_' {
b.WriteRune('-')
}
if b.Len() >= 40 {
if b.Len() >= 60 {
break
}
}