fix(upstream-triage): skip new upstream files inside a directory the fork removed (#656)

* fix(upstream-triage): skip new upstream files inside a directory the fork removed

A path absent from both HEAD and the merge base was always counted as new
upstream work, so a file added inside a tree the fork deleted (a test added
to a dropped portal) put the commit under "Worth reviewing" with a
cherry-pick that can only conflict. The nearest existing ancestor directory
now decides: present in HEAD means new work in a kept directory, present
only at the base means the fork removed the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* changelog: place the #656 entry under [Unreleased]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mads Lorentzen <madslorentzen_17@hotmail.com>
This commit is contained in:
authored and GitHub committed 2026-10-19 20:04:43 +02:00
1 parent 09a8c31b24
commit 93f37dde0b
3 files changed
+64 -2

No files matched your search

+31
View File
@@ -132,6 +132,37 @@ class RelevanceFilterTests(TriageRepoFixture):
self.assertEqual(git(self.root, "status", "--porcelain"), before)
self.assertFalse((self.root / "tools/new_workflow.py").exists())
def test_new_file_in_removed_directory_is_skipped(self):
# #586's shape: upstream adds a test file to a portal the fork dropped.
self.write("portals/gone/cli/src/cli.ts", "run()\n")
self.commit("shared: add portal")
self.write("portals/gone/cli/tests/new.test.ts", "test()\n")
self.commit("upstream: add a test to the portal")
self.set_upstream_to_head()
git(self.root, "reset", "--hard", "HEAD~1")
git(self.root, "rm", "-r", "portals/gone")
self.commit("fork: remove demo portal")
result = self.run_triage()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("**0** worth reviewing", result.stdout)
self.assertIn("touches only files not in this fork", result.stdout)
def test_new_directory_inside_kept_directory_is_worth_reviewing(self):
self.write("portals/kept/cli.ts", "run()\n")
self.commit("shared: add portal")
self.write("portals/kept/tests/new/case.test.ts", "test()\n")
added = self.commit("upstream: add nested tests to a kept portal")
self.set_upstream_to_head()
git(self.root, "reset", "--hard", "HEAD~1")
result = self.run_triage()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn("**1** worth reviewing", result.stdout)
self.assertIn(f"git cherry-pick {added}", result.stdout)
def test_new_tool_with_changelog_is_not_changelog_only(self):
self.write("CHANGELOG.md", "- base\n")
self.commit("shared: add changelog")