Skip to content

compile: re-adds ineffective merge=ours to .gitattributes, overwriting repo-owned policy #50583

Description

@loganrosen

Summary

gh aw compile rewrites the consuming repository's .gitattributes to append merge=ours to the lock-file entry. merge=ours is not a built-in git merge driver, so without a merge.ours.driver configuration it has no effect — while implying that generated-file conflicts are handled automatically.

Environment

  • gh-aw: observed on v0.84.3; code path still present on main (v0.85.1)
  • OS: macOS

Actual

Running gh aw compile changed an existing repository-owned line from:

.github/workflows/*.lock.yml linguist-generated=true

to:

.github/workflows/*.lock.yml linguist-generated=true merge=ours

No merge.ours.driver is defined anywhere by gh-aw, and nothing in the docs instructs users to define one.

Verification that the attribute is inert

mkdir /tmp/mergetest && cd /tmp/mergetest && git init -q .
echo "*.lock.yml merge=ours" > .gitattributes
echo a > f.lock.yml && git add -A && git commit -qm base
git checkout -qb feat && echo feat > f.lock.yml && git commit -qam feat
git checkout -q main && echo main > f.lock.yml && git commit -qam main
git merge feat

Result:

Auto-merging f.lock.yml
CONFLICT (content): Merge conflict in f.lock.yml
Automatic merge failed; fix conflicts and then commit the result.

Git has an ours merge strategy (-s ours) and an ours conflict-resolution option (-X ours), but no built-in merge driver named ours. merge=ours requires git config merge.ours.driver true in each clone to do anything.

Code pointers (on main)

  • pkg/constants/constants.go: const WorkflowsLockYmlGitAttributesEntry = WorkflowsLockYmlGlob + " linguist-generated=true merge=ours"
  • pkg/cli/git.goensureGitAttributes() actively rewrites pre-existing entries that start with the lock-yml glob to this exact string ("Updating old .gitattributes entry format"), so it overwrites deliberate repository policy rather than only appending when absent.
  • Invoked from pkg/cli/compile_infrastructure.go, pkg/cli/compile_file_operations.go, pkg/cli/add_workflow_compilation.go, pkg/cli/init.go.

Impact

  1. Repositories may believe generated lock-file conflicts are auto-resolved when they are not.
  2. Compilation mutates unrelated repository policy that the repo owner may have set intentionally, producing recurring diff churn on every compile.

Suggested behavior

  • Do not add merge=ours (keep linguist-generated=true only), or
  • If gh-aw needs deterministic conflict handling for generated files, ship a mechanism that actually works from repository-owned configuration (e.g. a documented merge.ours.driver setup step, or a documented regeneration-on-conflict workflow) and document it.
  • In either case, do not silently rewrite a pre-existing lock-yml .gitattributes line that the repository already owns.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions