fix: extract build_formula_issue_body to eliminate duplicate code blocks

Move TOML frontmatter construction into a shared helper in
lib/file-action-issue.sh, used by both gardener-poll.sh and
gardener-run.sh. Fixes CI duplicate-detection failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
openhands 2026-03-21 10:23:00 +00:00
parent 1782cbd610
commit 8193e7bc96
3 changed files with 18 additions and 16 deletions

View file

@ -134,16 +134,11 @@ Format: '1a 2c 3b' means question 1→option (a), 2→option (c), 3→option (b)
${ESCALATION_REPLY}" ${ESCALATION_REPLY}"
fi fi
ISSUE_BODY="--- _DESCRIPTION="Periodic gardener housekeeping run. The action-agent reads \`formulas/run-gardener.toml\`
formula: run-gardener
model: opus
---
Periodic gardener housekeeping run. The action-agent reads \`formulas/run-gardener.toml\`
and executes the steps: preflight, grooming, blocked-review, and executes the steps: preflight, grooming, blocked-review,
AGENTS.md update, and commit-and-pr.${ESCALATION_CONTEXT} AGENTS.md update, and commit-and-pr.${ESCALATION_CONTEXT}"
Filed automatically by \`gardener-poll.sh\`." ISSUE_BODY=$(build_formula_issue_body "run-gardener" "opus" "$_DESCRIPTION" "gardener-poll.sh")
_rc=0 _rc=0
file_action_issue "run-gardener" "action: run-gardener — periodic housekeeping" "$ISSUE_BODY" || _rc=$? file_action_issue "run-gardener" "action: run-gardener — periodic housekeeping" "$ISSUE_BODY" || _rc=$?

View file

@ -45,16 +45,11 @@ fi
log "--- Gardener run start ---" log "--- Gardener run start ---"
# ── File action issue for run-gardener formula ──────────────────────────── # ── File action issue for run-gardener formula ────────────────────────────
ISSUE_BODY="--- _DESCRIPTION="Periodic gardener housekeeping run. The action-agent reads \`formulas/run-gardener.toml\`
formula: run-gardener
model: opus
---
Periodic gardener housekeeping run. The action-agent reads \`formulas/run-gardener.toml\`
and executes the steps: preflight, grooming, blocked-review, and executes the steps: preflight, grooming, blocked-review,
AGENTS.md update, and commit-and-pr. AGENTS.md update, and commit-and-pr."
Filed automatically by \`gardener-run.sh\`." ISSUE_BODY=$(build_formula_issue_body "run-gardener" "opus" "$_DESCRIPTION" "gardener-run.sh")
_rc=0 _rc=0
file_action_issue "run-gardener" "action: run-gardener — periodic housekeeping" "$ISSUE_BODY" || _rc=$? file_action_issue "run-gardener" "action: run-gardener — periodic housekeeping" "$ISSUE_BODY" || _rc=$?

View file

@ -4,6 +4,9 @@
# Usage: source this file, then call file_action_issue. # Usage: source this file, then call file_action_issue.
# Requires: codeberg_api() from lib/env.sh, jq, lib/secret-scan.sh # Requires: codeberg_api() from lib/env.sh, jq, lib/secret-scan.sh
# #
# build_formula_issue_body <formula_name> <model> <description> <source_script>
# Outputs a standard issue body with TOML frontmatter to stdout.
#
# file_action_issue <formula_name> <title> <body> # file_action_issue <formula_name> <title> <body>
# Sets FILED_ISSUE_NUM on success. # Sets FILED_ISSUE_NUM on success.
# Returns: 0=created, 1=duplicate exists, 2=label not found, 3=API error, 4=secrets detected # Returns: 0=created, 1=duplicate exists, 2=label not found, 3=API error, 4=secrets detected
@ -12,6 +15,15 @@
# shellcheck source=secret-scan.sh # shellcheck source=secret-scan.sh
source "$(dirname "${BASH_SOURCE[0]}")/secret-scan.sh" source "$(dirname "${BASH_SOURCE[0]}")/secret-scan.sh"
# build_formula_issue_body <formula_name> <model> <description> <source_script>
# Builds a standard issue body with TOML frontmatter for formula-driven action issues.
# Outputs the body to stdout.
build_formula_issue_body() {
local formula_name="$1" model="$2" description="$3" source_script="$4"
printf -- '---\nformula: %s\nmodel: %s\n---\n\n%s\n\nFiled automatically by `%s`.' \
"$formula_name" "$model" "$description" "$source_script"
}
file_action_issue() { file_action_issue() {
local formula_name="$1" title="$2" body="$3" local formula_name="$1" title="$2" body="$3"
FILED_ISSUE_NUM="" FILED_ISSUE_NUM=""