mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: end profile history at a deleted namesake
This commit is contained in:
1 parent
e1c7ff316a
commit
3276754102
2 files changed
+30
-2
No files matched your search
+10
-2
@@ -3014,8 +3014,16 @@ def _git_history(path: Path) -> list[str] | None:
|
||||
|
||||
try:
|
||||
result = git("log", "--format=%H", "--", path.name)
|
||||
if result.returncode == 0:
|
||||
return result.stdout.split()
|
||||
deleted = git("log", "--format=%H", "--diff-filter=D", "--", path.name)
|
||||
if result.returncode == 0 and deleted.returncode == 0:
|
||||
# A commit that deletes or renames the file away ends the history
|
||||
# of the profile now at that path: what precedes it is another
|
||||
# profile once filed under the same name (mupen64plus.yml became
|
||||
# mupen64plus_next.yml before the standalone took the name).
|
||||
history = result.stdout.split()
|
||||
ends = set(deleted.stdout.split())
|
||||
cut = next((i for i, sha in enumerate(history) if sha in ends), len(history))
|
||||
return history[:cut]
|
||||
# A repository with no commit yet holds nothing written earlier.
|
||||
inside = git("rev-parse", "--is-inside-work-tree")
|
||||
if inside.stdout.strip() == "true" and git("rev-parse", "-q", "--verify", "HEAD").returncode:
|
||||
|
||||
@@ -4068,6 +4068,26 @@ class TestRealignProse(unittest.TestCase):
|
||||
messages = profile_sync.realign_prose(self.path, self.tmp.name, dry_run=True)
|
||||
self.assertTrue(any("unreadable" in m for m in messages), messages)
|
||||
|
||||
def test_a_deleted_namesake_is_not_the_profiles_history(self):
|
||||
"""mupen64plus.yml was renamed away in March, and a new standalone
|
||||
profile took the name in October. The deletion commit holds no file,
|
||||
so the older revisions were read as a gap and every note reported
|
||||
unreadable."""
|
||||
self._git("init", "-q")
|
||||
self._git("config", "user.email", "t@t")
|
||||
self._git("config", "user.name", "t")
|
||||
self._commit(
|
||||
PROSE_SAMPLE.replace('"pin"', '"older"').replace("a.c:10", "a.c:3"),
|
||||
"old profile",
|
||||
)
|
||||
self._git("rm", "-q", "p.yml")
|
||||
self._git("commit", "-m", "rename away")
|
||||
self._commit(PROSE_SAMPLE, "new profile")
|
||||
self.files[("pin", "a.c")] = ["x"] * 9 + ["subject"]
|
||||
self.assertEqual(
|
||||
profile_sync.realign_prose(self.path, self.tmp.name, dry_run=True), []
|
||||
)
|
||||
|
||||
def test_scalar_written_at_the_current_pin_is_left_alone(self):
|
||||
self._git("init", "-q")
|
||||
self._git("config", "user.email", "t@t")
|
||||
|
||||
Reference in new issue
Block a user