Skip to content

Commit 15c1972

Browse files
committed
Add script for syncing subtree
1 parent 4b1a23e commit 15c1972

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
git-subtree.sh

subtree-sync.sh

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
3+
set -eou pipefail
4+
5+
git fetch origin
6+
pushd $2
7+
git fetch origin
8+
popd
9+
10+
if [ "$(git rev-parse --show-prefix)" != "" ]; then
11+
echo "Run this script from the git root" >&2
12+
exit 1
13+
fi
14+
15+
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/master)" ]; then
16+
echo "$(pwd) is not at origin/master" >&2
17+
exit 1
18+
fi
19+
20+
if [ ! -f library/portable-simd/git-subtree.sh ]; then
21+
curl -sS https://raw.githubusercontent.com/bjorn3/git/tqc-subtree-portable/contrib/subtree/git-subtree.sh -o library/portable-simd/git-subtree.sh
22+
chmod +x library/portable-simd/git-subtree.sh
23+
fi
24+
25+
today=$(date +%Y-%m-%d)
26+
27+
case $1 in
28+
"push")
29+
upstream=rust-upstream-$today
30+
merge=sync-from-rust-$today
31+
32+
pushd $2
33+
git checkout master
34+
git pull
35+
popd
36+
37+
library/portable-simd/git-subtree.sh push -P library/portable-simd $2 $upstream
38+
39+
pushd $2
40+
git checkout -B $merge origin/master
41+
git merge $upstream
42+
popd
43+
echo "Branch \`$merge\` created in \`$2\`. You may need to resolve merge conflicts."
44+
;;
45+
"pull")
46+
branch=sync-from-portable-simd-$today
47+
48+
git checkout -B $branch
49+
echo "Creating branch \`$branch\`... You may need to resolve merge conflicts."
50+
library/portable-simd/git-subtree.sh pull -P library/portable-simd $2 origin/master
51+
;;
52+
esac

0 commit comments

Comments
 (0)