Skip to content

Commit b35cc50

Browse files
committed
Use git-filter-repo
1 parent 5859114 commit b35cc50

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

.github/workflows/update-subtree.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,25 @@ jobs:
4343
4444
- name: Update subtree/library locally
4545
run: |
46-
git remote add upstream https://github.com/rust-lang/rust
47-
git fetch upstream
46+
pushd ..
47+
git clone [email protected]:newren/git-filter-repo
48+
git clone https://github.com/rust-lang/rust rust-tmp
49+
cd rust-tmp
4850
4951
# Ensure "upstream/master" branch contains the target commit
5052
if ! git show ${COMMIT_HASH} --oneline --no-patch; then
5153
echo "Rust commit ${COMMIT_HASH} cannot be found."
5254
exit 1
5355
fi
5456
55-
# subtree/library has the subtree-split variant of a commit that previously
56-
# went into upstream/master. Running `git subtree split` on top of the
57-
# original commit (i.e., the commit from upstream/master) is much faster (my experiment when working on 280k+
58-
# commits: 113 seconds vs 613 seconds) than using the HEAD commit from
59-
# subtree/library as base.
60-
SUBTREE_HEAD=$(git log --format=%s -n 1 origin/subtree/library)
61-
echo "SUBTREE_HEAD: ${SUBTREE_HEAD}"
62-
UPSTREAM_ONTO=$(git log --grep="$SUBTREE_HEAD" -n 1 --format=%H upstream/master)
63-
echo "UPSTREAM_ONTO: ${UPSTREAM_ONTO}"
64-
6557
git checkout ${COMMIT_HASH}
66-
git subtree split --prefix=library --onto $UPSTREAM_ONTO -b subtree/library
58+
../git-filter-repo/git-filter-repo --subdirectory-filter library --force
59+
git checkout -b subtree/library
60+
popd
61+
git remote add rust-filtered ../rust-tmp/
62+
git fetch rust-filtered
63+
git checkout -b update-subtree/library rust-filtered/subtree/library
64+
git rebase origin/subtree/library
6765
6866
- name: Create Pull Request
6967
uses: peter-evans/create-pull-request@v7
@@ -83,7 +81,7 @@ jobs:
8381
git submodule update --init
8482
8583
# This command may fail, which will require human intervention.
86-
if ! git subtree merge --prefix=library subtree/library --squash; then
84+
if ! git subtree merge --prefix=library update-subtree/library --squash; then
8785
echo "MERGE_CONFLICTS=yes" >> $GITHUB_ENV
8886
git commit -a -m "Merge from $COMMIT_HASH with conflicts"
8987
else

0 commit comments

Comments
 (0)