From 161a56299c275099e981eeab7d33e8798bf38363 Mon Sep 17 00:00:00 2001 From: Juri Leino Date: Fri, 18 Oct 2024 16:35:55 +0200 Subject: [PATCH] fix(github): handle edge-case in github:aggregate-filechanges An existing file can be removed and then added by **renaming** another file to the previously removed one. This will now be handled gracefully. --- src/modules/github.xql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/github.xql b/src/modules/github.xql index b86b2a7..7b5ceb7 100644 --- a/src/modules/github.xql +++ b/src/modules/github.xql @@ -162,7 +162,8 @@ declare function github:aggregate-filechanges ($changes as map(*), $next as map( map:put($changes, "new", ($changes?new[. ne $next?filename], $next?filename)) case "renamed" return let $new := map:put($changes, "new", ($changes?new, $next?filename)) - return map:put($new, "del", ($changes?del, $next?previous_filename)) + (: account for files that existed, were removed in one commit and then reinstated by renaming a file :) + return map:put($new, "del", ($changes?del[. ne $next?filename], $next?previous_filename)) case "removed" return (: ignore this document, if it was added _and_ removed in the same changeset :) if ($next?filename = $changes?new)