Repository navigation
Description
Problem or Motivation
Row 9 of devops repos onboard (Template pull request) cannot correct a template pull request that an earlier run opened with a wrong answer.
Read on 2026-11-26 on #7307, which a run with the default release_type: simple opened with version.txt:
- A second run with
--release-type pythonplans onlyadd .copier-answers.yml.template_rowofsrc/devops_cli/github/onboard/template_pr.pypushes the files that are absent or differ; it removes no file that the new baseline does not hold. Soversion.txtstays on the branch. - The branch is
ci/repository-template(src/devops_cli/github/onboard/routes.py:27). The commit hook of the repository refuses a commit on it:branch name is <type>/<issue>-<slug> or copilot/<slug> (CONTRIBUTING.md, Naming). The command writes its commit through the API, so no person or agent can correct the branch with git.
The only way out is to close the pull request, delete the branch and run the command again.
Proposed Solution
Disposition: change the code.
- When a template pull request is open, the run makes the tree of its branch equal to the baseline for the template files: it adds, replaces and removes. A file that only an earlier baseline held, such as
version.txt, goes. The plan printsremove <path>for it. - The branch name follows the naming rule of the repositories, or the hook accepts the template branch by name. Name the choice in the plan of this item.
Proof: a test over the fake GitHub API with an open template pull request that holds version.txt, and a baseline with no such file, gives a tree with no version.txt and the change line remove version.txt.
Existing Tool Considered
The git data API of GitHub (trees and commits), which the row already uses. A tree entry with sha: null removes a path.
Alternatives check of 2026-11-26: in-use.
The repository already uses this tool.
Tool: copier-org/copier (https://github.com/copier-org/copier), MIT, last activity 2026-11-26, maintained.
Reason: Searches found Copier, the template engine behind the baseline's .copier-answers.yml. It re-renders a project and applies the template diff with deletions, but it cannot drive the open branch through the API, so the row still needs code.
Covers:
- Re-renders the project from the new baseline with the new answers
- Applies the template diff, including deletions of dropped files
- Keeps answers in .copier-answers.yml for a repeatable render
Lacks:
- No tree push to an open pull request branch over the API
- No plan lines such as
remove <path> - No branch-name rule for the commit hook
- Needs a local clone and git, not a fake GitHub API
Proposed design
Problem statement
Row 9 of devops repos onboard cannot correct an open template pull request that an earlier baseline filled with a file the new baseline lacks: the branch keeps the stale file, so the only way out is to close the pull request, delete the branch and run the command again. The branch ci/repository-template is also outside the branch-name rule, so a person cannot commit a correction on it. The change makes row 9 build the branch's tree from the default branch and the new baseline, so a file of an old baseline goes and the plan says remove <path>, and it lets the hook accept the template branch by name.
Acceptance criteria
Requirement: Remove a file of an old baseline
Row 9 SHALL remove from the template branch each file that an earlier run of the row wrote and the new baseline does not hold.
Scenario: Open template pull request with a dropped file
- WHEN The open template pull request branch holds
version.txt, the default branch holds each file of the new baseline, and the new baseline holds noversion.txt. - THEN
tests/github/onboard/test_onboard_rows.py::test_template_row_removes_dropped_baseline_filepasses: the branch tree of the fake GitHub API holds noversion.txt, and the row changes holdremove version.txt.
Requirement: Plan the removal without a write
Row 9 SHALL show each removed path as remove <path> in a plan and SHALL send no tree write in a plan.
Scenario: Plan of a dropped file
- WHEN The open template pull request branch holds
version.txt, the new baseline holds noversion.txt, andwriter.confirmis false. - THEN
tests/github/onboard/test_onboard_rows.py::test_template_row_plans_removal_without_writepasses: the row changes holdremove version.txt, and the fake API records notemplate-treerequest.
Requirement: Keep a file of the default branch
Row 9 SHALL keep a path that the default branch holds and the new baseline does not hold.
Scenario: Default branch file outside the baseline
- WHEN The default branch and the template branch hold
README.md, and the new baseline holds noREADME.md. - THEN
tests/github/onboard/test_onboard_rows.py::test_template_row_keeps_default_branch_filepasses: the branch tree still holdsREADME.md, and the row changes hold noremove README.md.
Requirement: Match the default branch outside the template files
Row 9 SHALL give each path that the new baseline does not hold the text of the default branch.
Scenario: Branch copy of a default branch file differs
- WHEN The template branch holds
README.mdwith text other than the default branch'sREADME.md, and the new baseline holds noREADME.md. - THEN
tests/github/onboard/test_onboard_rows.py::test_template_row_restores_default_branch_textpasses: the branch tree holds the default branch's text ofREADME.md.
Requirement: Accept the template branch in the hook
The branch-name pre-commit hook MUST accept ci/repository-template as an exact branch name beside the two branch forms.
Scenario: Template branch passes the hook
- WHEN The checkout is on the branch
ci/repository-template, anduv run pre-commit run branch-name --all-filesruns. - THEN The command reports
Passed; on a checkout of a branch namedci/otherthe same command reportsFailed.
Existing Tool Considered
Copier (copier-org/copier), the tool that the alternatives block of the issue body names with the verdict in-use and that the baseline already uses. Its block lists what the tool lacks for row 9, so the row keeps its thin adapter over the GitHub Git data API that it already uses (src/devops_cli/github/onboard/template_pr.py:148), about 60 lines, at a written cost of about 25,000 tokens and 3 hours to build, keep and fix.
Key questions
- How does row 9 make the tree of the open template branch lose a path that the new baseline does not hold?: This run found no verified source for a tree entry whose
shaisnull, so row 9 does not use it. It sends the tree of the default branch's head commit asbase_treeand adds the baseline files that the default branch lacks, so a path of an old baseline is in neither the default branch's tree nor the entries and goes. A plan reads the tree of the template branch head and the tree of the default branch head withrecursive=1and names each path that is on the branch, absent from the default branch and absent from the baseline asremove <path>; the confirmed run sends the same one tree request, which the row already sends (src/devops_cli/github/onboard/template_pr.py:161). (best practice) [sources: src/devops_cli/github/onboard/template_pr.py:161, src/devops_cli/github/onboard/template_pr.py:165, tests/support/github_repository.py:750, src/devops_cli/github/onboard/routes.py:368]- Rejected: Send a tree entry with
sha: nullfor each removed path. No source of this run states that behavior, and the fake GitHub API of the tests merges only entries that holdcontent(tests/support/github_repository.py:750-754). - Chosen: Build the tree from the default branch's tree and the baseline files it lacks. It uses the
base_treerequest that the row already sends (src/devops_cli/github/onboard/template_pr.py:161-171), so the branch holds exactly the default branch's tree plus the template files the repository lacks. - Rejected: Report the removals from the file list of the pull request. The list names changes, not the tree, and GitHub caps it, so it cannot show that the default branch lacks a path.
- Rejected: Send a tree entry with
- Which branch-name rule applies to
ci/repository-template?: Keepci/repository-templateand add it as an exact third alternative of thebranch-namehook's--pattern, with the hook's name and comment stating it. Do not weaken the general rule. The name is outside<type>/<issue>-<slug>because the form needs an issue number and the target repository has no issue for the template, and a rename would orphan each open template pull request. (best practice) [sources: CONTRIBUTING.md:206, src/devops_cli/github/onboard/routes.py:28, .pre-commit-config.yaml:20, openspec/specs/branch-name-hook/spec.md:8]- Rejected: Rename the branch to a
<type>/<issue>-<slug>name. The target repository has no issue for the template, the issue number would name another repository's issue, and a rename orphans each open template pull request. - Chosen: Add
ci/repository-templateto the exact accepted names. It keeps the machine branch and the open pull request, and it leaves the general rule intact. - Rejected: Accept every branch under
ci/. It weakens the hook for each branch and hides a wrong name.
- Rejected: Rename the branch to a
- How does row 9 select the paths to remove from an open template branch?: Read the tree of the head of
TEMPLATE_BRANCHand the tree of the default branch head, and remove a path only when it is on the template branch, absent from the default branch and absent from the new baseline. (best practice) [sources: src/devops_cli/github/onboard/template_pr.py:245, src/devops_cli/github/onboard/routes.py:368]- Rejected: Remove every path of the branch that the new baseline lacks. It removes files that the default branch owns.
- Chosen: Compare the branch tree with the default branch tree and the new baseline. It removes only paths that the template pull request added and the new baseline dropped.
- Rejected: Use the files list of the open pull request. The list shows changes, not the full tree. It cannot prove that a path is absent from the default branch.
- Does row 9 reconcile an open template branch when the default branch holds every baseline file?: Yes. The open branch can hold a file of an old baseline while the default branch holds every file of the new baseline, so row 9 reconciles the open branch before it returns
PRESENT; it returnsPRESENTonly when the branch tree already equals the default branch's tree plus the baseline files that the default branch lacks. (best practice) [sources: src/devops_cli/github/onboard/template_pr.py:247, src/devops_cli/github/onboard/template_pr.py:252]- Rejected: Return
PRESENTwhen the default branch holds every baseline file. It leaves the stale file on the open template branch. - Chosen: Reconcile the open template branch before the
PRESENTresult. It removes the stale file and keeps the open pull request usable.
- Rejected: Return
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 26, 2026
Both target the same command and the same template PR area, but #7309 fixes how answers are read while the candidate fixes how the template row syncs the tree (removal) and the branch name.devops-cli-service commentedon Nov 26, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (10)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.243.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.243.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 03:13 UTC