Skip to content

Commit 6cf992c

Browse files
committed
Subtree update automation: update submodules
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.
1 parent 9949c4a commit 6cf992c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/update-subtree.yml

Lines changed: 11 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,9 +184,14 @@ 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+
for d in $(cat ../submodule-heads | cut -f2 -d" ") ; do git reset HEAD $d ; done
188+
git submodule foreach 'grep $sm_path $toplevel/../submodule-heads | cut -f1 -d" " | xargs git checkout'
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
192+
git submodule foreach 'grep $sm_path $toplevel/../submodule-heads | cut -f1 -d" " | xargs git checkout'
193+
git -c user.name=gitbot -c user.email=git@bot \
194+
commit -m "Update submodules" library/
184195
fi
185196
git replace -d subtree/library
186197
git replace -d main~1

0 commit comments

Comments
 (0)