Skip to content

Commit 613f27d

Browse files
authored
Subtree update automation: update submodules (#394)
Update submodules to the exact version that upstream uses at the commit that we are trying to merge towards. We never modify the contents of submodules, so we don't need to make any attempt to merge changes and instead can directly pick the right upstream version. See https://github.com/tautschnig/verify-rust-std/actions/runs/15846078305/job/44668465448 for a successful run and tautschnig#25 for the ensuing PR (which, notably, includes [a commit that bumps submodules](tautschnig@54d1d40)). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 26d30a0 commit 613f27d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

.github/workflows/update-subtree.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
if: ${{ env.SUBTREE_PR_EXISTS == 'no' }}
8686
run: |
8787
cd splitsh-lite
88+
sudo apt-get update
8889
sudo apt-get install -y golang libgit2-dev
8990
# git2go upstream hasn't been updated to more recent versions of
9091
# libgit2, so using a fork that does stay up to date
@@ -110,6 +111,10 @@ jobs:
110111
fi
111112
112113
git checkout ${NEXT_COMMIT_HASH}
114+
# Collect submodule commits; note that submodules (intentionally!)
115+
# aren't initialized, hence lines will be prefixed with "-" (see git
116+
# submodule --help).
117+
git submodule status -- library/ | sed 's/^-//' > ../submodule-heads
113118
/usr/bin/time -v ../splitsh-lite/splitsh-lite --progress --prefix=library --target subtree/library
114119
git checkout -b subtree/library subtree/library
115120
@@ -165,6 +170,7 @@ jobs:
165170
fi
166171
fi
167172
git checkout main
173+
git submodule foreach 'git fetch'
168174
169175
# Tell git about the correct merge base to use, which is the subtree
170176
# head that we last merged from.
@@ -178,6 +184,8 @@ jobs:
178184
-c user.name=gitbot -c user.email=git@bot \
179185
merge -Xsubtree=library subtree/library; then
180186
echo "MERGE_CONFLICTS=yes" >> $GITHUB_ENV
187+
# Ignore submodule conflicts, those are dealt with below.
188+
for d in $(cat ../submodule-heads | cut -f2 -d" ") ; do git reset HEAD $d ; done
181189
git -c user.name=gitbot -c user.email=git@bot commit -a -m "Merge from $NEXT_COMMIT_HASH with conflicts"
182190
else
183191
echo "MERGE_CONFLICTS=no" >> $GITHUB_ENV
@@ -187,6 +195,12 @@ jobs:
187195
NEW_SUBTREE_HEAD=$(git rev-parse subtree/library)
188196
echo "NEW_SUBTREE_HEAD=${NEW_SUBTREE_HEAD}" >> $GITHUB_ENV
189197
198+
# Set submodules to upstream versions
199+
git submodule update --init
200+
git submodule foreach 'grep $sm_path $toplevel/../submodule-heads | cut -f1 -d" " | xargs git checkout'
201+
git -c user.name=gitbot -c user.email=git@bot \
202+
commit -m "Update submodules" library/
203+
190204
sed -i "s/^channel = \"nightly-.*\"/channel = \"nightly-${NEXT_TOOLCHAIN_DATE}\"/" rust-toolchain.toml
191205
git -c user.name=gitbot -c user.email=git@bot \
192206
commit -m "Update toolchain to ${NEXT_TOOLCHAIN_DATE}" rust-toolchain.toml

0 commit comments

Comments
 (0)