-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing the rebase/squash issue #617
Comments
@mmcev106 , in which cases are there skipped commits? Also, when you update the parent manually, how do you determine which sha to use? From what I've seen, when there is a subrepo pull/push, the Originally, after a rebase on the |
@taktran, if you're only expecting changes to be made in one place, skipping commits should be OK, as the pull will overwrite with the latest (as you said). We have changes made in both the repo directly, and on it's subrepo clone inside a containing repo. Skipping any commit on either end potentially overwrites changes we want made on the opposite end. To recover from #602 I run Rebasing is of course unsupported, as there's no way for git-subrepo to know where it was once the commits are re-written. I'm guessing this also works for you because commits are only moving in one direction. |
@mmcev106 Oh I see. We've made rebase the default, which is more difficult when there are conflicts, but our team is pretty small and are ok with having a soft "lock" on shared folder files when we are making changes, coordinating manually to ensure we don't get into messy situations. I guess our compromise of simple locking and manual coordination allows us to not have to deal with distributed repo git syncing issues 😅 It's still early days though, and we haven't seen all the issues that can arise from this. |
I did not find it immediately obvious how to gather the information needed to fix a missing parent error. Search the repository for the values needed and present them as part of the message. Fixes ingydotnet#617, ingydotnet#415, ingydotnet#600
I've encountered the issue where if you squash or rebase the container repository containing the subrepo folder, the
.gitrepo
>subrepo.parent
value gets stale because the commit shas have changed. Any, subsequentgit subrepo push
orgit subrepo pull
will give the error:There are numerous github issues that highlight this issue, and the general solution seems to be to modify the
subrepo.parent
value manually. However, I have a work around that appears to work, but would love comments on whether it's a good approach, and if so, maybe we can get it merged into the repo properly.My approach is to create a script that wraps
git subrepo
and handles the case where the parent sha is stale, and fixes it, then runs thegit subrepo
command again. If it isn't stale, it just runs the command as normal. The steps are:Check if the
subrepo.parent
value is stale withIt returns an error code if the parent sha can't be found, otherwise it returns nothing.
I got the idea of how to check this from Clear error when rebase has broken parent reference #415
If it is stale, do the extra step of:
Run the
git subrepo
command as normalAs a cleanup task, if the parent was stale, I squash the commit of the
git subrepo
with the extra commit for updating.gitrepo
(step 2).Essentially, step 2 is a temporary step, just to get
git subrepo
commands to work, and once it works, that commit is no longer necessary. I'm not 100% sure this will work for all cases, but it works for the typical github PR flow that rebases or squashes commits. With this script, it doesn't matter if the parent sha is stale from a rebase, as it will be "cleaned" up when the next person runs the script.Here is the implementation: https://github.com/ag-grid/ag-website-shared/blob/78c8d85224fcc688cd446273ea50a6ffbfbde8d9/scripts/subrepo/src/lib/runSubRepoCommand.ts (the folder containing it, wraps it in a CLI, so that it can be run in the container repositories).
Can anyone see any downsides to this approach?
Other issues that highlight this problem:
git subrepo pull/branch
fails after force-pushing to remote #541The text was updated successfully, but these errors were encountered: