forked from Special-K-s-Flightsim-Bots/DCSServerBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch-branch.sh
More file actions
48 lines (42 loc) · 1.16 KB
/
switch-branch.sh
File metadata and controls
48 lines (42 loc) · 1.16 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
#!/bin/bash
# Enable error handling
set -e
# Get the directory of the script file
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$script_dir"
# Get current branch from .git/HEAD
if [ ! -f .git/HEAD ]; then
echo "Error: .git/HEAD file not found. Are you inside a Git repository?"
exit 1
fi
branch=$(awk '{print $2}' .git/HEAD)
branch=${branch#refs/heads/} # Trim the branch name
# Switch to the other branch
if [ "$branch" == "master" ]; then
read -p "Switch to development branch? [y/N] " choice
case "$choice" in
[yY])
git checkout development
./update.sh # Call the equivalent `update.cmd` script in Bash
;;
*)
echo "Operation aborted."
exit 0
;;
esac
elif [ "$branch" == "development" ]; then
read -p "Switch to master branch? [y/N] " choice
case "$choice" in
[yY])
git checkout master
./update.sh # Call the equivalent `update.cmd` script in Bash
;;
*)
echo "Operation aborted."
exit 0
;;
esac
else
echo "Unknown branch: $branch"
exit 1
fi