forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_move.sh
executable file
·78 lines (65 loc) · 1.92 KB
/
update_move.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
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Copyright (c) Mysten Labs, Inc.
# SPDX-License-Identifier: Apache-2.0
set -e
if ! command -v git &> /dev/null; then
echo "Please install git" >&2
exit 1
fi
if ! command -v sed &> /dev/null; then
echo "Please install sed" >&2
exit 1
fi
if ! command -v cargo-hakari &> /dev/null; then
echo "Please install cargo-hakari (via cargo)" >&2
exit 1
fi
DEFAULT_REMOTE="https://github.com/move-language/move"
DEFAULT_BRANCH="sui-move"
while getopts ":r:b:h" OPT; do
case $OPT in
r)
REMOTE=$OPTARG ;;
b)
BRANCH=$OPTARG ;;
h)
>&2 echo "Usage: $0 [-h] [-r REMOTE] [-b BRANCH]"
>&2 echo ""
>&2 echo "Options:"
>&2 echo " -r REMOTE The git remote to find the move repository at."
>&2 echo " (Default: $DEFAULT_REMOTE)"
>&2 echo " -b BRANCH The branch to depend on."
>&2 echo " (Default: $DEFAULT_BRANCH)"
>&2 exit 0
;;
\?)
>&2 echo "Unrecognized option '$OPTARG'"
exit 1
;;
esac
done
REMOTE=${REMOTE:-$DEFAULT_REMOTE}
BRANCH=${BRANCH:-$DEFAULT_BRANCH}
COMMIT=$(git ls-remote "$REMOTE" "$BRANCH" | cut -f1)
REPO=$(git rev-parse --show-toplevel)
>&2 echo "Updating Move Cargo dependency"
>&2 echo "Sui Repo : $REPO"
>&2 echo "Move Repo : $REMOTE"
>&2 echo "Move Branch : $BRANCH"
>&2 echo "Move Commit : $COMMIT"
>&2 echo ""
>&2 echo "Updating $REPO/Cargo.toml ..."
sed -i '' -f - "$REPO/Cargo.toml" <<EOS
/^move-/!b
s!git = "[^"]*"!git = "$REMOTE"!
s!rev = "[^"]*"!rev = "$COMMIT"!
EOS
>&2 echo "Updating $REPO/.config/hakari.toml ..."
sed -i '' -f - "$REPO/.config/hakari.toml" <<EOS
/name = "move-/!b
s!git = "[^"]*"!git = "$REMOTE"!
s!rev = "[^"]*"!rev = "$COMMIT"!
EOS
>&2 echo "Running \`cargo hakari generate\` ..."
cargo hakari generate
>&2 echo "Done!"