-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit.sh
More file actions
executable file
·56 lines (48 loc) · 1.51 KB
/
git.sh
File metadata and controls
executable file
·56 lines (48 loc) · 1.51 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
#!/bin/bash
## Available Commands:
# $PWD/git.sh check
# $PWD/git.sh reset
# $PWD/git.sh update
# Host UBoot ## Add to ~/.ssh/config for SSH support, recommend ecdsa-sk or ed25519_sk.
# Hostname github.com
# IdentityFile ~/.ssh/id_ecdsa_sk
# IdentitiesOnly yes
yubi_check() {
while [[ $(lsusb) != *Yubikey* ]]; do printf "\rPlease insert yubikey...\033[K"; done;
if [[ $(ls -la /dev/hidraw0) = *root* ]]; then
pkexec chown $(whoami):$(whoami) /dev/hidraw*
fi
}
git_reset() {
git reset --hard
git clean -xfd
env | sort >> Results/env/git.env && echo "" >> Results/env/git.env
}
git_update() {
echo "Fetching recent changes..."
if [[ $(<~/.ssh/config) == *UBoot* ]]; then
yubi_check
git remote remove origin && git remote add origin git@UBoot:0mniteck/U-Boot.git
read -p "Origin set to SSH; Continue git pull..."
fi
git pull $(git remote -v | awk '{ print $2 }' | tail -n 1) $(git rev-parse --abbrev-ref HEAD)
env | sort >> Results/env/git.env && echo "" >> Results/env/git.env
}
if [[ "$1" == *check* ]]; then
yubi_check
exit 0
elif [[ "$1" == *reset* ]]; then
git_reset
exit 0
elif [[ "$1" == *update* ]]; then
git_update
exit 0
fi
git status && git add -A && git status
if [[ $(<~/.ssh/config) == *UBoot* ]]; then
yubi_check
fi
pkexec --keep-cwd git commit -a -S -m "$1" && sleep 5 && git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD):Docker
if [ "$2" != "" ]; then
pkexec --keep-cwd git tag -a "$2" -s -m "Tagged Release $2" && sleep 5 && git push origin "refs/tags/$2"
fi