Skip to content

Commit b664d13

Browse files
committed
Subtree update automation: use fast version of subtree split
repo-filter was fast, but wouldn't produce consistent SHA hashes. This made incremental non-interactive updates of the branch a matter of luck as git may or may not be able to automatically resolve conflicts. (It worked for the update to 2025-02-10, but failed for the next one.) git-subtree-split does produce consistent SHA hashes, but the native `git-subtree-split` implementation is a shell script, and thus was found to be too slow (which is why we chose repo-filter in the first place). splitsh-lite is an implementation of just the `subtree split` command in Go and libgit2.
1 parent 05d9d56 commit b664d13

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

.github/workflows/update-subtree.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defaults:
1111

1212
jobs:
1313
update-subtree-library:
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-24.04
1515

1616
steps:
1717
- name: Checkout Repository
@@ -34,12 +34,6 @@ jobs:
3434
fetch-depth: 0
3535
path: rust-tmp
3636

37-
- name: Checkout git-filter-repo
38-
uses: actions/checkout@v4
39-
with:
40-
repository: newren/git-filter-repo
41-
path: git-filter-repo
42-
4337
- name: Fetch toolchain versions
4438
run: |
4539
CURRENT_TOOLCHAIN_DATE=$(grep -oP 'channel = "nightly-\K\d{4}-\d{2}-\d{2}' verify-rust-std/rust-toolchain.toml)
@@ -77,6 +71,23 @@ jobs:
7771
env:
7872
GH_TOKEN: ${{ github.token }}
7973

74+
- name: Checkout splitsh-lite
75+
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
76+
uses: actions/checkout@v4
77+
with:
78+
repository: splitsh/lite
79+
path: splitsh-lite
80+
81+
- name: Build splitsh-lite
82+
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
83+
run: |
84+
cd splitsh-lite
85+
sed -i 's#github.com/libgit2/git2go#github.com/jeffwelling/git2go#' go.mod splitter/*
86+
sed -i -e 's/v34/v37/g' go.mod splitter/*.go
87+
sed -i 's/v37.0.0/v37.0.4/' go.mod
88+
go mod tidy
89+
go build -o splitsh-lite github.com/splitsh/lite
90+
8091
- name: Update subtree/library locally
8192
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
8293
run: |
@@ -89,16 +100,13 @@ jobs:
89100
fi
90101
91102
git checkout ${NEXT_COMMIT_HASH}
92-
../git-filter-repo/git-filter-repo --subdirectory-filter library --force
93-
git checkout -b subtree/library
103+
/usr/bin/time -v ../splitsh-lite/splitsh-lite --progress --prefix=library --target subtree/library
104+
git checkout -b subtree/library subtree/library
94105
95106
cd ../verify-rust-std
96107
git remote add rust-filtered ../rust-tmp/
97108
git fetch rust-filtered
98109
git checkout -b subtree/library rust-filtered/subtree/library
99-
# The filter-subtree operation adds an extraneous `library/` folder containing the submodules
100-
# (c.f. https://github.com/model-checking/verify-rust-std/issues/249), so remove that before committing.
101-
rm -rf library
102110
SUBTREE_HEAD_MSG=$(git log --format=%s -n 1 origin/subtree/library)
103111
UPSTREAM_FROM=$(git log --grep="${SUBTREE_HEAD_MSG}" -n 1 --format=%H rust-filtered/subtree/library)
104112
UPSTREAM_HEAD=$(git log --format=%H -n 1 rust-filtered/subtree/library)
@@ -107,7 +115,7 @@ jobs:
107115
echo "MERGE_CONFLICTS=noop" >> $GITHUB_ENV
108116
else
109117
git branch --set-upstream-to=origin/subtree/library
110-
git -c user.name=gitbot -c user.email=git@bot rebase
118+
git -c user.name=gitbot -c user.email=git@bot rebase --rebase-merges
111119
echo "MERGE_CONFLICTS=maybe" >> $GITHUB_ENV
112120
fi
113121

0 commit comments

Comments
 (0)