[Bug]: files deleted in template not being removed in PR #551
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When a file is deleted in the template repository, the PR opened by the action does not delete the file in the current repo (I'm using "current repo" here to be the repo I'm currently working on that was created from the template and that I'd like to apply the template changes to).
Expected Behavior
I expected any file deleted in the parent repo to also be deleted after the action is run.
Current Behavior
The file removed from the template repo is not removed in the current repo, even with IS_FORCE_DELETION: true and GIT_REMOTE_PULL_PARAMS: --allow-unrelated-histories --squash --strategy=recursive -X theirs --no-edit. This is discussed in an open PR starting here. As noted there, I tried with multiple combinations of git_remote_pull_params to no avail.
Steps To Reproduce
To dig in further, I tried imitating what actions-template-sync does locally by adding the original template repo as an upstream to my current repo. I noticed that pulling using the same flags resulted in none of the deleted files being tracked.
Possible Solution
I ultimately tracked down this excellent explanation of how git handles merging with --allow-unrelated-histories, which as best as I can tell is likely the issue. One possible solution I found uses git replace --graft to create an artificial common history point.
git fetch upstream main
git replace --graft <ocal_current_git_hash> <a_hash_on_parent_before_used_template>
git merge --allow-unrelated-histories --squash --strategy=recursive -X theirs --no-edit --no-rebase
UPDATE (I found an error in which hash I used for the graft): This successfully identified the deleted files and a run of git status suggests at least all the right files have been touched. I'm not sure if this would be the preferred approach to addressing this bug (I'm already out of my usual depth in git), but if someone can help with designing the best approach I'll take a stab at implementing a solution.
Additional Information/Context
No response
Template sync version Version
2.2.3
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Activity
AndreasAugustin commentedon Jul 23, 2024
Hi @JessicaS11 and thanks for the bug report.
I try to find some time to look into the issue ASAP
JessicaS11 commentedon Aug 1, 2024
Just wanted to add a note that we're going to port in the remainder of the changes manually for the repo linked above ("current behavior") because we need it for an event. But, we can use this one as an ongoing test case (it tracks the same template and is otherwise a scratch repo).
AndreasAugustin commentedon Aug 1, 2024
@JessicaS11 thanks a lot for the sample.
WolfGreyDev commentedon Nov 6, 2024
I too am running into problems with
IS_FORCE_DELETION: truenot preforming the action while using theGIT_REMOTE_PULL_PARAMSrecommended settings.This suggests
IS_FORCE_DELETIONactive but as you can see, no files are selected. I'm not sure if something is broken, or if the documentation isn't up to date with working settings.AndreasAugustin commentedon Nov 11, 2024
Hi @WolfGreyDev and thanks for the addon.
Unfortunately I was not able yet to take a closer look. Hopefully will finish some other projects soon to get some more time available.
fix(#551): fix issue with file deletion
fix(#551): fix issue with file deletion
fix(#551): fix issue with file deletion (#596)
AndreasAugustin commentedon Jan 7, 2025
Hi @JessicaS11 super sorry for the super long wait time. I was really busy with other tasks I needed to focus on (which actually are needed to pay my bills)
The issue should be gone with next fix version
v2.4.2.Some details within #596 .
The issue was a bad refactoring mistake which has lead to a bad race condition.
JessicaS11 commentedon Jan 27, 2025
Thanks for the fix, @AndreasAugustin! I totally understand (darn those pesky bills!). I look forward to trying it out.
AndreasAugustin commentedon Jan 29, 2025
@JessicaS11 thanks for the offer. Unfortunately it seems the issue is still not fixed for any reason. But I have an idea to finally solve the issue (and others coming with squashed commits).
#596 (comment)