|
| 1 | +--- |
| 2 | +name: resolve-refcache-conflicts |
| 3 | +description: |
| 4 | + Skill for resolving static/refcache.json merge or rebase conflicts in the |
| 5 | + current branch or a specified PR. |
| 6 | +argument-hint: '[optional-pr-number]' |
| 7 | +--- |
| 8 | + |
| 9 | +`static/refcache.json` is an auto-generated file. Resolving conflicts requires |
| 10 | +first taking the integration branch's side, finishing the merge/rebase, then |
| 11 | +running `npm run fix:refcache` to restore any URLs unique to the active branch. |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +If the current branch has a merge or rebase in progress, then skip the rest of |
| 16 | +this section and jump to **Preparation**. |
| 17 | + |
| 18 | +The current branch must be clean (`git status --short`). If not clean, offer to |
| 19 | +run `git stash` or `git commit` to clean it up, or stop. |
| 20 | + |
| 21 | +If `$ARGUMENTS` is a PR number, then check out the PR branch with: |
| 22 | +`gh pr checkout $ARGUMENTS`. |
| 23 | + |
| 24 | +## Preparation |
| 25 | + |
| 26 | +At this point, we are ready to resolve the conflicts in the active branch: |
| 27 | + |
| 28 | +1. Determine the integration reference (`$BASE_BRANCH`) and fetch it: |
| 29 | + - If an `upstream` remote exists: `git fetch upstream`, use `upstream/main`. |
| 30 | + - Otherwise: `git fetch origin`, use `origin/main`. |
| 31 | + |
| 32 | +2. If merge or rebase is in progress (`git status`), skip this step. Otherwise, |
| 33 | + ask the user whether to run `git merge $BASE_BRANCH` or |
| 34 | + `git rebase $BASE_BRANCH`, then run it. |
| 35 | + |
| 36 | +3. If there are no conflicts: stop, we are done. |
| 37 | + |
| 38 | +4. Conflicts other than `static/refcache.json`: resolve them with the user. |
| 39 | + |
| 40 | +5. If no `static/refcache.json` conflict remains: stop, we are done. Otherwise, |
| 41 | + proceed to **Resolve**. |
| 42 | + |
| 43 | +## Resolve |
| 44 | + |
| 45 | +1. Check out the `$BASE_BRANCH` version of `static/refcache.json`. Assumes the |
| 46 | + active branch is being rebased/merged from `$BASE_BRANCH`, not the other way |
| 47 | + around: |
| 48 | + |
| 49 | + | Operation | Command | |
| 50 | + | ------------------------------------------- | -------------------------------------------- | |
| 51 | + | Rebase of active branch onto `$BASE_BRANCH` | `git checkout --ours static/refcache.json` | |
| 52 | + | Merge of `$BASE_BRANCH` into active branch | `git checkout --theirs static/refcache.json` | |
| 53 | + |
| 54 | +2. Stage the resolved files, then continue: |
| 55 | + - Rebase: `git add static/refcache.json && git rebase --continue` |
| 56 | + - Merge: `git add static/refcache.json && git commit --no-edit` |
| 57 | + - If other files were resolved in Preparation step 4, `git add` those too |
| 58 | + before continuing. |
| 59 | + |
| 60 | +3. Rebase only: for each subsequent rebase stop that conflicts on |
| 61 | + `static/refcache.json`, repeat Resolve steps 1–2. If other paths are also |
| 62 | + conflicted on that stop, run Preparation step 4 first. |
| 63 | + |
| 64 | +4. Run `npm run fix:refcache` once, after the entire rebase/merge completes. |
| 65 | + Note: this runs a full Hugo build and link check — requires network, |
| 66 | + installed npm dependencies, and populated submodules; can take several |
| 67 | + minutes. |
| 68 | + |
| 69 | +5. Commit the changes, if any: |
| 70 | + |
| 71 | + ```sh |
| 72 | + git add static/refcache.json |
| 73 | + git diff --cached --quiet static/refcache.json || \ |
| 74 | + git commit -m "Refresh refcache after resolving conflicts" |
| 75 | + ``` |
| 76 | + |
| 77 | +6. Push: |
| 78 | + - Merge: `git push` |
| 79 | + - Rebase: `git push --force-with-lease` |
0 commit comments