forked from Mirobit/bitcoin-node-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd.sh
More file actions
124 lines (103 loc) · 2.95 KB
/
cmd.sh
File metadata and controls
124 lines (103 loc) · 2.95 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT_DIR"
ENV_FILE="${ROOT_DIR}/.env"
if [[ -f "$ENV_FILE" ]]; then
set -a
# shellcheck disable=SC1090
source "$ENV_FILE"
set +a
fi
TAG_RELEASE="${TAG_RELEASE:-$(date +"%y.%m%d.%S")}"
SOLODEV_RELEASE="${SOLODEV_RELEASE:-$TAG_RELEASE}"
AWS_PROFILE="${AWS_PROFILE:-develop}"
readonly ROOT_DIR ENV_FILE TAG_RELEASE SOLODEV_RELEASE AWS_PROFILE
usage() {
cat <<'EOF'
Usage: ./cmd.sh <command> [args]
Commands:
help Show this help
bundle Build the submodule bundle artifact
upstream-status Show origin/upstream remote and branch status
upstream-add Add the Mirobit repo as upstream
upstream-fetch Fetch upstream refs
upstream-log Show recent upstream commits not yet in this branch
upstream-diff Show file-level diff summary between this branch and upstream/master
upstream-pull Fast-forward merge upstream/master into current branch
upstream-merge Merge upstream/master into current branch with a merge commit if needed
upstream-rebase Rebase current branch onto upstream/master
EOF
}
has_upstream() {
git remote get-url upstream >/dev/null 2>&1
}
bundle() {
docker-compose -f docker-compose.bundle.yml up --build
}
upstream-status() {
git remote -v
echo
git branch -vv
if has_upstream; then
echo
echo "ahead/behind vs upstream/master:"
git rev-list --left-right --count HEAD...upstream/master
fi
}
upstream-add() {
if has_upstream; then
echo "upstream already configured"
git remote get-url upstream
return 0
fi
git remote add upstream https://github.com/Mirobit/bitcoin-node-manager.git
git remote get-url upstream
}
upstream-fetch() {
has_upstream || upstream-add
git fetch upstream
}
upstream-log() {
has_upstream || upstream-add
git log --oneline HEAD..upstream/master | sed -n '1,20p'
}
upstream-diff() {
has_upstream || upstream-add
git diff --stat HEAD..upstream/master
}
upstream-pull() {
has_upstream || upstream-add
git fetch upstream
git merge --ff-only upstream/master
}
upstream-merge() {
has_upstream || upstream-add
git fetch upstream
git merge --no-ff upstream/master
}
upstream-rebase() {
has_upstream || upstream-add
git fetch upstream
git rebase upstream/master
}
command_name="${1:-help}"
shift || true
case "$command_name" in
help|-h|--help) usage ;;
bundle) bundle ;;
upstream-status) upstream-status ;;
upstream-add) upstream-add ;;
upstream-fetch) upstream-fetch ;;
upstream-log) upstream-log ;;
upstream-diff) upstream-diff ;;
upstream-pull) upstream-pull ;;
upstream-merge) upstream-merge ;;
upstream-rebase) upstream-rebase ;;
*)
echo "Unknown command: $command_name" >&2
echo
usage
exit 1
;;
esac