-
Notifications
You must be signed in to change notification settings - Fork 804
/
Copy pathsnowbridge_update_subtree.sh
executable file
·66 lines (57 loc) · 2.22 KB
/
snowbridge_update_subtree.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# A script to update bridges repo as subtree to Cumulus
# Usage:
# ./scripts/update_subtree_snowbridge.sh fetch
# ./scripts/update_subtree_snowbridge.sh patch
set -e
SNOWBRIDGE_BRANCH="${SNOWBRIDGE_BRANCH:-main}"
POLKADOT_SDK_BRANCH="${POLKADOT_SDK_BRANCH:-master}"
SNOWBRIDGE_TARGET_DIR="${TARGET_DIR:-bridges/snowbridge}"
function fetch() {
# the script is able to work only on clean git copy
[[ -z "$(git status --porcelain)" ]] || {
echo >&2 "The git copy must be clean (stash all your changes):";
git status --porcelain
exit 1;
}
local snowbridge_remote=$(git remote -v | grep "snowbridge.git (fetch)" | head -n1 | awk '{print $1;}')
if [ -z "$snowbridge_remote" ]; then
echo "Adding new remote: 'snowbridge' repo..."
git remote add -f snowbridge https://github.com/Snowfork/snowbridge.git
snowbridge_remote="snowbridge"
else
echo "Fetching remote: '${snowbridge_remote}' repo..."
git fetch https://github.com/Snowfork/snowbridge.git --prune
fi
echo "Syncing/updating subtree with remote branch '${snowbridge_remote}/$SNOWBRIDGE_BRANCH' to target directory: '$SNOWBRIDGE_TARGET_DIR'"
git subtree pull --prefix=$SNOWBRIDGE_TARGET_DIR ${snowbridge_remote} $SNOWBRIDGE_BRANCH --squash
}
function clean() {
echo "Patching/removing unneeded stuff from subtree in target directory: '$SNOWBRIDGE_TARGET_DIR'"
chmod +x $SNOWBRIDGE_TARGET_DIR/parachain/scripts/verify-pallets-build.sh
$SNOWBRIDGE_TARGET_DIR/parachain/scripts/verify-pallets-build.sh --ignore-git-state --no-revert
}
function create_patch() {
[[ -z "$(git status --porcelain)" ]] || {
echo >&2 "The git copy must be clean (stash all your changes):";
git status --porcelain
exit 1;
}
echo "Creating diff patch file to apply to snowbridge. No Cargo.toml files will be included in the patch."
git diff snowbridge/$SNOWBRIDGE_BRANCH $POLKADOT_SDK_BRANCH:bridges/snowbridge --diff-filter=ACM -- . ':(exclude)*/Cargo.toml' > snowbridge.patch
}
case "$1" in
fetch)
fetch
;;
clean)
clean
;;
create_patch)
create_patch
;;
update)
fetch
clean
;;
esac