Skip to content

Commit

Permalink
fix(github): handle edge-case in github:aggregate-filechanges
Browse files Browse the repository at this point in the history
An existing file can be removed and then added by **renaming** another file to the previously removed one.
This will now be handled gracefully.
  • Loading branch information
line-o committed Oct 18, 2024
1 parent 6f3f8a5 commit 161a562
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modules/github.xql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 161a562

Please sign in to comment.