-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Rebasing the Migration Branch on Latest Master [ARCHIVED]
NOTE: This page describes deprecated processes. It is maintained in case we have a future project that needs similar steps.
Since we cannot freeze release of new documentation while working on the Redocly migration, our approach is to maintain two branches:
- The
masterbranch continues to work on Dactyl until we are ready for a final "code freeze" (<2 weeks) to switch over. - The
redocly-migrationbranch contains Redocly-specific work and is periodically re-based onmaster.
This page describes how to do the rebase.
- Pull the latest
masterandredocly-migrationbranches to your local Git instance.
git switch master
git pull
git switch redocly-migration
git pull- On the
redocly-migrationbranch, start an interactive rebase
git rebase -i
-
In the interactive "to-do" list, there are several things you want to do:
- Drop commits tagged with
[DROP], by changingpicktodrop(ord). In the following cases, you should also add abreakline after that so you can manually re-create the commit on the latest master:- The commit to move
assets/tocontent/static/. If no assets have changed in the master branch since the last rebase, you can skip this and leave the previous[DROP]commit in-place (leave it aspick). - The
[DROP] Migrate content syntaxcommit. This is the main result of running the script.
- The commit to move
- In some other cases, you can drop a commit with no further action. Examples of these include commits that applied some migration script updates, temporary fixes to content that were also rolled into the migration script, or temporary fixes that are no longer necessary due to updates to Redocly. These commits should be tagged with
[DROP]but we might miss one or two. - Move and squash commits tagged with
[FOLD], typically ones that modify the migration script. Keep them in the same order relative to one another, changepicktos(for squash), and move them to be afterCreate script to migrate links and content syntaxand before the[DROP] Migrate content syntax. - Optionally, you can fix up other commits, like using
r(reword) to correct a commit message that isn't quite right.
Tip: If you're using
vimfor editing git's to-do list, useddto cut andpto paste lines. It may also be useful to copy-paste the entire to-do list to a text file in another window to help you orient yourself while you do the rest of the rebase.When you've got the to-do list how you want it, save and exit. This starts the rebase.
- Drop commits tagged with
-
Git may interrupt the rebase for a merge conflict. If you aren't sure, use
git statusand your text file of the entire to-do list to orient yourself to what needs doing.Merge conflicts can occur because a commit in the
redocly-migrationbranch touched on a line that either (a) got updated inmastersince the last rebase, or (b) was handled differently by the migration script compared with last time. You need to actually look at each individual conflict and decide how to resolve it: sometimes one version or the other is correct, or sometimes you need a combination of the two. Usegit addto mark resolution of the files as you go, and dogit rebase --continuewhen you've finished resolving merge conflicts. -
Git also pauses the rebase at the explicit
breakpoints you've set. When this comes up, re-create the migration commit as needed.For the "Migrate content syntax" commit, run
tool/migrate.sh, which may take a few minutes to finish while being mostly quiet. Any messages it outputs to the console are probably worth paying attention to, although you may not need to take immediate action. When it's done,git add content/ tool/andgit commitwith a commit message such as the following:[DROP] Migrate content syntax (2024-01-22 v4) The changes in this commit were auto-generated by doing: tool/migrate.sh When rebasing the migration branch on the latest master, this commit should be dropped and re-created (probably using the same command).(Rome's note: I've taken to adding the date, and if it takes me more than one try to get it right, a version number, to the top of the commit message.)
If you encounter problems with the migration script(s), you can use commands like
git checkout -- contentorgit reset --hardto reset it, although you might separately need to remove untracked files and folders likerm content/@i18n/ja/_snippets/. Then you can edit the scripts or other files and re-run them. If things work right, you should commit the changes to the scripts first (as[FOLD]commits for next time).For the static files migration, the commands to re-create the commit are
git mv assets content/staticandgit mv img content/imgand the commit message can be something like the following:[DROP] Move static files to content dir The changes in this commit were generated by doing: git mv assets content/static git mv img/ content/img When rebasing the migration branch on the latest master, this commit should be dropped and re-created (possibly using the same command).(Edit the message accordingly if you do things differently, like if this is after re-levelization and you're moving
assetstostaticat the top level instead.)After you've re-created the commit, use
git rebase --continueto resume the rebase. -
Continue fixing merge conflicts as they come up.
-
When you are done, you should have a rebased
redocly-migrationbranch that has many different commits than the one in the upstream repo. Check that your local branch works OK, for example by doing these commands:npm i npm run start
Test out the site on the local dev server and make sure things are reasonable. If something's wrong, you may want to add more commits to fix it, or do a
git rebase --abortand start over (which may be your best option if the migration script needed fixes). -
If it seems fine, force-push the branch to GitHub and notify collaborators that you've done so.
git push -f
This may also be a good time to remind people of the instructions for rebasing their feature branches.