-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit.sh
More file actions
executable file
·60 lines (54 loc) · 1.01 KB
/
Copy pathcommit.sh
File metadata and controls
executable file
·60 lines (54 loc) · 1.01 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
MESSAGE=""
PUSH=0
usage() {
cat <<EOF
Usage: ./commit.sh <message> [--push]
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--push|-p)
PUSH=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
if [[ -z "$MESSAGE" ]]; then
MESSAGE="$1"
else
MESSAGE+=" $1"
fi
shift
;;
esac
done
if [[ -z "$MESSAGE" ]]; then
usage
exit 1
fi
echo "=== PrintMaster Commit Script ==="
echo
echo "[1/3] Building agent and server..."
"$SCRIPT_DIR/build.sh" both
echo "Build succeeded!"
echo
echo "[2/3] Staging and committing changes..."
git -C "$SCRIPT_DIR" add -A
git -C "$SCRIPT_DIR" commit -m "$MESSAGE"
echo "Committed successfully!"
echo
if [[ "$PUSH" == "1" ]]; then
echo "[3/3] Pushing to remote..."
git -C "$SCRIPT_DIR" push
echo "Pushed successfully!"
else
echo "[3/3] Skipping push (use --push to push automatically)"
fi
echo
echo "=== Done ==="