Skip to content

fix: selectively git add known files in maintenance update command#25370

Merged
pelikhan merged 2 commits intomainfrom
copilot/update-agentic-maintenance-command
Apr 8, 2026
Merged

fix: selectively git add known files in maintenance update command#25370
pelikhan merged 2 commits intomainfrom
copilot/update-agentic-maintenance-command

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 8, 2026

Summary

The run_operation_update_upgrade.cjs script previously used git status --porcelain to discover all changed files, then filtered out .github/workflows/ paths. This deny-list approach could accidentally stage temporary files created during the update/upgrade process.

Changes

  • Added KNOWN_FILES_UPDATE allowlist: only .github/aw/actions-lock.json (the only non-workflow file that gh aw update can modify)
  • Added KNOWN_FILES_UPGRADE allowlist: actions-lock.json, agent files, and old deprecated agent files that may be deleted by the upgrade process
  • Replaced the git status discovery + filter flow with: attempt to git add each known file (warn and continue on error), then check git diff --cached --name-only for what was actually staged
  • Branch creation and commit now happen after confirming staged changes (avoids creating empty branches)
  • Updated tests: removed git status mock, added explicit allowlist behavior tests

Test Results

All 20 tests pass (npx vitest run actions/setup/js/run_operation_update_upgrade.test.cjs).

Related

Fixes the issue seen at https://github.com/github/gh-aw/actions/runs/24151113577/job/704780671

Copilot AI requested a review from pelikhan April 8, 2026 19:13
@pelikhan pelikhan marked this pull request as ready for review April 8, 2026 19:13
Copilot AI review requested due to automatic review settings April 8, 2026 19:13
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 8, 2026

@copilot merge main and recompile

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the maintenance update/upgrade automation to stage only an explicit allowlist of “known safe” files (rather than discovering changes via git status), reducing the risk of accidentally committing temporary files.

Changes:

  • Introduces update/upgrade allowlists and stages only those paths, then derives the PR file list from git diff --cached --name-only.
  • Moves branch creation/commit until after staged changes are confirmed (avoids empty branches/PRs).
  • Updates unit tests to reflect allowlist-based staging behavior.
Show a summary per file
File Description
actions/setup/js/run_operation_update_upgrade.cjs Replaces deny-list git status discovery with allowlist-based git add + staged-diff verification; delays branch creation until after staging is confirmed.
actions/setup/js/run_operation_update_upgrade.test.cjs Updates mocks/assertions to validate allowlist staging and staged-diff behavior.
.github/workflows/refactoring-cadence.lock.yml Quotes ${RUNNER_TEMP} script paths / adds bash invocation changes.
.github/workflows/design-decision-gate.lock.yml Quotes ${RUNNER_TEMP} script paths / adds bash invocation changes.
.github/workflows/deep-report.lock.yml Updates locked workflow content (quoting, prompt IDs/hashes, and an env var expression change).
.github/workflows/architecture-guardian.lock.yml Quotes ${RUNNER_TEMP} script paths / adds bash invocation changes.
.github/workflows/approach-validator.lock.yml Quotes ${RUNNER_TEMP} script paths / adds bash invocation changes.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 3

".github/agents/setup-agentic-workflows.md",
".github/agents/update-agentic-workflows.md",
".github/agents/upgrade-agentic-workflows.md",
".github/aw/upgrade-agentic-workflow.md",
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KNOWN_FILES_UPGRADE includes .github/aw/upgrade-agentic-workflow.md, but this repo (and existing references) use .github/aw/upgrade-agentic-workflows.md (plural). As written, git add will fail for the intended upgrade prompt file and any changes to it won’t be included in the upgrade PR. Update the allowlist entry to the correct path (and keep any truly-deprecated paths separate if needed).

Suggested change
".github/aw/upgrade-agentic-workflow.md",
".github/aw/upgrade-agentic-workflows.md",

Copilot uses AI. Check for mistakes.
Comment on lines +111 to +115
try {
await exec.exec("git", ["add", "--", file]);
} catch (error) {
core.warning(`Failed to stage '${file}': ${getErrorMessage(error)}`);
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The staging loop warns on any git add failure. With the current upgrade allowlist including deprecated/old paths (e.g., .github/aw/schemas/agentic-workflow.json), many repos will hit pathspec ... did not match any files every run after those files are already removed, creating noisy action logs. Consider treating “pathspec did not match” as a non-warning (skip silently or log at info/debug), or pre-check whether the path exists/is tracked before attempting to stage it, while still allowing deletions to be staged.

Suggested change
try {
await exec.exec("git", ["add", "--", file]);
} catch (error) {
core.warning(`Failed to stage '${file}': ${getErrorMessage(error)}`);
}
const { exitCode, stdout, stderr } = await exec.getExecOutput(
"git",
["add", "--", file],
{ ignoreReturnCode: true },
);
if (exitCode === 0) {
continue;
}
const gitAddOutput = [stdout, stderr].filter(Boolean).join("\n");
if (/pathspec .* did not match any file/i.test(gitAddOutput)) {
core.info(`Skipping staging for '${file}': path does not exist or is not tracked`);
continue;
}
core.warning(`Failed to stage '${file}': ${gitAddOutput || `git add exited with code ${exitCode}`}`);

Copilot uses AI. Check for mistakes.
Comment on lines 148 to 151
# poutine:ignore untrusted_checkout_exec
run: |
bash ${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh
bash "${RUNNER_TEMP}/gh-aw/actions/create_prompt_first.sh"
{
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description focuses on changing the maintenance update/upgrade staging logic, but this PR also modifies several locked workflow files (mostly adding bash + quoting around ${RUNNER_TEMP} paths, and other env tweaks). Please confirm these workflow changes are intentional and update the PR description accordingly so reviewers understand the full scope.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 9fb1155 into main Apr 8, 2026
71 of 74 checks passed
@pelikhan pelikhan deleted the copilot/update-agentic-maintenance-command branch April 8, 2026 19:18
Copilot stopped work on behalf of pelikhan due to an error April 8, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants