Skip to content

--include-paths over-attributes issues from stale-branch merges (follow-up to #62) #102

Closed

Description

@lukemelia

Summary

#62 added --full-history to getCommitContextsBetweenShas so that merge commits
aren't dropped as TREESAME under a --include-paths pathspec — correctly fixing
the case where a feature branch's issue key lives only on the merge subject. But
bare --full-history keeps a merge unless it is TREESAME to all parents, which
over-includes: a stale feature branch (branched from older main, merged
without rebasing) is not TREESAME to its branch parent for any path that advanced
on main while it was open, so its merge — and the issue key in its subject — is
attributed to releases for paths the branch never touched.

Impact

In a polyglot monorepo we run one release pipeline per deployable surface
(backend, several frontend apps, mobile), each scoped with --include-paths. The
leak makes each surface's release issue list a superset of what that surface
shipped. With a cross-pipeline reconciler that marks an issue Shipped only once
all its attached releases reach production, a foreign attachment is worse than
cosmetic: an issue that only touched surface A stays unshipped until unrelated
surface B also deploys. Measured on real history (v0.14.0): filtering a 32-commit
range to one app's subtree pulled in 1–2 issues from other apps every time —
because most PRs lag main by merge time, this is the common case.

Reproduction (git-level — the query the CLI runs)

git init -q repo && cd repo && mkdir -p app-a
echo a0 > app-a/file && git add . && git commit -qm init            # app-b does NOT exist yet
git checkout -q -b feat/ABC-1-thing                                  # branch rooted here (stale)
echo a1 > app-a/file && git commit -qam "ABC-1 work (app-a only)"
git checkout -q main
mkdir -p app-b && echo b0 > app-b/file && git add . && git commit -qm "add app-b on main"
git merge -q --no-ff feat/ABC-1-thing -m "Merge pull request #1 from org/feat/ABC-1-thing"

git log --full-history --oneline -- ':(top,glob)app-b/**'
#   <merge> Merge pull request #1 from org/feat/ABC-1-thing   <-- LEAKED: branch touched only app-a
#   <c>     add app-b on main

sync --include-paths="app-b/**" then attributes ABC-1 (from the leaked merge's
branch name) to an app-b-only release.

Why the obvious fix (--simplify-merges) is wrong

Adding --simplify-merges stops the leak but reintroduces the exact bug #62
fixed
: it drops a merge whose merged-in work does touch the paths when the
issue key lives only on the merge subject (no content commit carries it):

# feature branch touches app-b; key only in branch name / merge subject:
git log --full-history --simplify-merges --oneline -- ':(top,glob)app-b/**'
#   <c> implement the thing (no key here)        <-- merge dropped, key LOST

So the two flags trade one bug for the other.

Proposed fix

Keep --full-history, but when extracting an issue key from a merge commit
under an active path filter, attribute it only if the merge's net effect on those
paths is non-empty:

git diff <merge>^1 <merge> -- <pathspec>   # non-empty => merge delivered changes here => attribute

This is the precise discriminator between the two cases (verified on both repros
above):

merge diff ^1..merge -- app-b attribute to app-b?
stale branch, app-a only (empty) no ✓
real work touching app-b, key on subject only app-b/file yes ✓

Net merges (no real changes on the filtered paths) contribute no key; merges that
actually delivered changes to the surface still contribute their subject key —
preserving #62's fix. Happy to open a PR with this plus tests covering both cases.

Environment

  • linear-release v0.14.0 (prebuilt binary)
  • git <fill in git --version>

Activity

  1. linear-code commented on Jun 8, 2026

    @linear-code
    Contributor
  2. added
    bug
    on Jun 8, 2026
  3. changed the title [-]`--include-paths` over-attributes issues from unrelated paths (`--full-history` used without `--simplify-merges`)[/-] [+]`--include-paths` over-attributes issues from stale-branch merges (follow-up to #62)[/+] on Jun 8, 2026
  4. laander commented on Jun 9, 2026

    @laander

    Thanks for reporting! This will be fixed in the next release of the CLI 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Release CLIbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions