From 9767b09ea66f09e38791e10c956b0423edc1430a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 09:55:50 +0000 Subject: [PATCH 1/4] fix: make publish commits independent of local git identity Agent-Logs-Url: https://github.com/disk0Dancer/climate/sessions/d6040e63-4a42-4668-a3e1-05c9bbb48634 Co-authored-by: disk0Dancer <89835485+disk0Dancer@users.noreply.github.com> --- internal/publish/publish.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/publish/publish.go b/internal/publish/publish.go index 9c75ae0..5cfb84c 100644 --- a/internal/publish/publish.go +++ b/internal/publish/publish.go @@ -343,7 +343,7 @@ Not-tested: Remote release workflow execution if err := os.WriteFile(messagePath, []byte(message), 0o644); err != nil { return fmt.Errorf("writing git commit message: %w", err) } - return runGit(sourceDir, "commit", "-F", messagePath) + return runGitCommit(sourceDir, messagePath) } func runGit(dir string, args ...string) error { @@ -356,6 +356,21 @@ func runGit(dir string, args ...string) error { return nil } +func runGitCommit(dir, messagePath string) error { + args := []string{ + "-c", "user.name=climate", + "-c", "user.email=climate@users.noreply.github.com", + "commit", "-F", messagePath, + } + cmd := exec.Command("git", args...) //nolint:gosec + cmd.Dir = dir + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("git %s: %w\n%s", strings.Join(args, " "), err, string(out)) + } + return nil +} + // PublishedManifestEntry returns a manifest entry updated with repository metadata. func PublishedManifestEntry(entry manifest.CLIEntry, result *Result) manifest.CLIEntry { entry.RepositoryURL = result.RepositoryURL From ed45b6a699bc7b9868891b34b8ce66d1afcd18cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 09:56:44 +0000 Subject: [PATCH 2/4] test: clone explicit main branch in publish verification Agent-Logs-Url: https://github.com/disk0Dancer/climate/sessions/d6040e63-4a42-4668-a3e1-05c9bbb48634 Co-authored-by: disk0Dancer <89835485+disk0Dancer@users.noreply.github.com> --- internal/publish/publish_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/publish/publish_test.go b/internal/publish/publish_test.go index 3d02672..b81a408 100644 --- a/internal/publish/publish_test.go +++ b/internal/publish/publish_test.go @@ -91,7 +91,7 @@ func TestSyncGitRepositoryExistingRepoPreservesRemoteFiles(t *testing.T) { } verifyDir := t.TempDir() - if err := runGit("", "clone", remoteBare, verifyDir); err != nil { + if err := runGit("", "clone", "--branch", "main", remoteBare, verifyDir); err != nil { t.Fatalf("clone verify repo: %v", err) } readme, err := os.ReadFile(filepath.Join(verifyDir, "README.md")) From 52332eb0cd2917f5b2b9be0143b07c07cb2e819a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Apr 2026 09:59:00 +0000 Subject: [PATCH 3/4] refactor: reuse runGit in publish commit helper Agent-Logs-Url: https://github.com/disk0Dancer/climate/sessions/d6040e63-4a42-4668-a3e1-05c9bbb48634 Co-authored-by: disk0Dancer <89835485+disk0Dancer@users.noreply.github.com> --- internal/publish/publish.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/publish/publish.go b/internal/publish/publish.go index 5cfb84c..a64e887 100644 --- a/internal/publish/publish.go +++ b/internal/publish/publish.go @@ -362,13 +362,7 @@ func runGitCommit(dir, messagePath string) error { "-c", "user.email=climate@users.noreply.github.com", "commit", "-F", messagePath, } - cmd := exec.Command("git", args...) //nolint:gosec - cmd.Dir = dir - out, err := cmd.CombinedOutput() - if err != nil { - return fmt.Errorf("git %s: %w\n%s", strings.Join(args, " "), err, string(out)) - } - return nil + return runGit(dir, args...) } // PublishedManifestEntry returns a manifest entry updated with repository metadata. From 4208cb7639cdbaad05af7da8ece8ef2d7a28ae73 Mon Sep 17 00:00:00 2001 From: disk0dancer Date: Thu, 23 Apr 2026 13:19:47 +0300 Subject: [PATCH 4/4] ci: make the autofix workflow resilient to branch races The auto-fix workflow now checks out the PR head repository with full history and rebases its formatting/lint fix commit onto the latest branch tip before pushing. This reduces false failures when CI auto-fix runs after the branch has moved or when the branch requires a fetch-first update before push. Constraint: Keep the auto-fix flow limited to the head repository and branch from the failed CI run Rejected: Blind push without refresh | still fails on common non-fast-forward races Confidence: high Scope-risk: narrow Reversibility: clean Directive: Treat CI auto-fix as a rebasing updater, not as a one-shot blind pusher Tested: workflow YAML reviewed locally; local repo checks on PR branch remain green (go test ./..., go vet ./..., golangci-lint run) Not-tested: live GitHub Actions execution of the updated workflow --- .github/workflows/ci-autofix.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-autofix.yml b/.github/workflows/ci-autofix.yml index ca8b75f..105b78a 100644 --- a/.github/workflows/ci-autofix.yml +++ b/.github/workflows/ci-autofix.yml @@ -24,7 +24,9 @@ jobs: - name: Checkout failed branch uses: actions/checkout@v4 with: + repository: ${{ github.event.workflow_run.head_repository.full_name }} ref: ${{ github.event.workflow_run.head_branch }} + fetch-depth: 0 - name: Stop on stale branch head id: freshness @@ -79,7 +81,10 @@ jobs: git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add -A git commit -m "ci: auto-fix formatting and lint" - git push origin HEAD:${{ github.event.workflow_run.head_branch }} + branch="${{ github.event.workflow_run.head_branch }}" + git fetch origin "${branch}" + git pull --rebase origin "${branch}" + git push origin HEAD:"${branch}" - name: Re-dispatch CI if: steps.changes.outputs.changed == 'true'