Skip to content

fix(repos): a kept template file conflicts at copier update #7411

Description

@dan-petty

Problem

devops repos onboard keeps each template file that the repository already holds with other text (template_row, src/devops_cli/github/onboard/template_pr.py:216-236), but the template pull request adds .copier-answers.yml. Copier then treats each kept file as a file of the template. The next copier update from Renovate makes a 3-way merge of the kept file, and each change of the template near a changed line gives conflict markers. The Renovate pull request then cannot merge.

Evidence

Proposed Solution

Disposition: decide the owner of a kept file, then change the code. Two forms:

  • The template pull request also brings each kept file to the text of the template, with the facts of the repository as answers (fix(repos): onboard reads the template answers from the repository #7309 reads the scopes from .github/labels.yml). Then the next update has the template text as its base and applies with no conflict.
  • Or the repository stays the owner, and the answers file records it so that copier update does not touch the file (Copier --skip, skip_if_exists).

Existing Tool Considered

Copier, in use: copier update does the 3-way merge, and skip_if_exists keeps a file that exists. No tool chooses the owner of a file that both the repository and the template hold.

Acceptance criteria

  • A test renders the template over a repository that holds .github/labels.yml with other text, runs copier update to a newer tag of the template, and finds no conflict marker.

Related: #7309 (the answers of onboard), dan-petty/infra#214 (the SHA pin of the callers).

Alternatives check of 2026-11-27: 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 no tool beyond Copier, which the issue already names as in use: it runs the 3-way update merge and can skip an existing file, but it decides no owner for a kept file, so the conflict remains.

Covers:

  • Three-way merge of a template update to a newer ref
  • Keeps a destination file that already exists
  • Records the template and answers in a file

Lacks:

  • No per-file decision of which side owns it
  • Kept file still enters the update merge and conflicts
  • No exclusion of a kept file from later merges

Proposed design

Problem statement

devops repos onboard keeps each template file that the repository already holds with other text. The template pull request adds .copier-answers.yml, so Copier treats the kept file as a template file. The next copier update merges the kept file against a changed template and writes conflict markers. The Renovate pull request then cannot merge.

Acceptance criteria

Requirement: Template text replaces a kept file

template_row SHALL write the rendered template text for a kept file and SHALL return no kept path.

Scenario: Repository holds a labels file with another header

  • WHEN A test calls template_row with a fake repository, a fake baseline, and a fake writer. The repository holds .github/labels.yml with another header.
  • THEN The writer records one write of .github/labels.yml with the text baseline.files[".github/labels.yml"]. The kept paths that template_row returns are empty.

Requirement: A kept file alone opens the template pull request

template_row SHALL open the template pull request when the repository holds at least one kept file and lacks no template file.

Scenario: Repository holds every template file with other text

  • WHEN A test calls template_row with a fake repository that holds each template file with other text. The repository has no open template pull request.
  • THEN The writer records the create of branch ci/repository-template and draft pull request ci: add the files of the repository template.

Requirement: Pending a person after the merge

After the merge, a copier update to the next template tag MUST apply with no conflict on a kept file.

Scenario: Copier update of a repository that kept its labels file

  • WHEN A person runs copier update --skip-answered --defaults --vcs-ref <the next tag> --conflict inline in a clone. The repository onboarded while it held .github/labels.yml with other text.
  • THEN git status --porcelain lists no unmerged path. .github/labels.yml holds no <<<<<<<, ======= or >>>>>>> marker.

Existing Tool Considered

Copier (https://github.com/copier-org/copier), in use; the alternatives check of 2026-11-27 in the issue body records what Copier covers and lacks. The change makes the template the owner of each kept file: it writes the rendered template text, so the next copier update uses that text as the base.

Key questions

  • Where does the onboard command decide to keep a template file that the repository already holds with other text?: _file_states compares the template files at the baseline ref with the repository. It returns the files that the repository holds with other text as kept. template_row receives that kept list. [sources: src/devops_cli/github/onboard/template_pr.py:80, src/devops_cli/github/onboard/template_pr.py, docs/repos/onboard.md]
  • Which form of the proposed solution should the change take?: The template pull request writes the rendered template text for each kept file. A repository fact that differs becomes an answer in .copier-answers.yml, not an edit of the file. The file then equals the template text that the next copier update uses as its base. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md, openspec/changes/archive/2026-11-22-6773-repos-onboard/design.md, openspec/specs/repos-onboard/spec.md, docs/repos/onboard.md]
    • Chosen: Template text, with the repository facts as answers. ADR 0035 gives the onboard command ownership of the repository settings. The answers keep the write lossless, so the file becomes the base of the next update and the conflict goes. The change amends the spec rule that a kept file stays.
    • Rejected: Template text over every kept file, with no answer for its facts. The 2026-11-22 design rejected this overwrite because it undoes the repository's changes at each run.
    • Rejected: A skip in the answers file. The alternatives check records that Copier has no exclusion of a kept file from later merges. The kept file still enters the update merge, so the conflict remains.
  • Does the answers file make Copier skip a kept file?: No. The alternatives check of 2026-11-27 in the issue body records that a kept file still enters the update merge and that Copier has no exclusion of a kept file from later merges. read_answers reads the answers file that the command writes. [sources: src/devops_cli/github/onboard/baseline.py:94]
  • Does the rendered labels file keep the repository's scopes?: Only when .copier-answers.yml holds the scopes answer. A render with no scopes answer writes the default scopes and drops the scope/* labels of the repository. fix(repos): onboard reads the template answers from the repository #7309 fills that answer from .github/labels.yml, so this change depends on fix(repos): onboard reads the template answers from the repository #7309. [sources: src/devops_cli/github/onboard/baseline.py, docs/repos/onboard.md]
  • What does the template row do when the repository lacks no template file?: It reads the check runs of the open template pull request. The change also opens the template pull request when the repository holds at least one kept file, because the rendered text is a change that the row must push. (best practice) [sources: docs/repos/onboard.md, src/devops_cli/github/onboard/template_pr.py]
    • Chosen: Open the template pull request for a kept file. The rendered text is a change to the repository. A later run has no missing file to write, so the row must open the pull request now.
    • Rejected: Keep the row at present and wait. No later run writes the rendered text, so the kept file still conflicts at the next copier update.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#7309

Activity

  1. added
    type/bug
    source/agent
    on Nov 27, 2026
  2. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    value/medium
    effort/medium
    scope/repos
    priority/p2-medium
    on Nov 27, 2026
  4. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    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 (7)

    Tools considered:

    Searches run:

    • copier skip_if_exists update conflict markers kept files, results: 5
    • copier template update avoid conflicts on files the project owns, results: 5
    • copier-org copier documentation skip_if_exists, results: 5
    • cruft cookiecutter template update skip files, results: 5
    • copier update three-way merge template answers file, results: 5
    • Copier project template updater Python, results: 5
    • template sync tool keep local file changes during update git, results: 5

    Sources:

  5. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  6. added
    status/ready
    and removed
    status/new
    on Nov 29, 2026
  7. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    status/in-progress
    and removed
    status/ready
    on Nov 29, 2026
  9. removed
    status/in-progress
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/repossource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions