-
Notifications
You must be signed in to change notification settings - Fork 0
/
push
executable file
·80 lines (70 loc) · 1.49 KB
/
push
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
#!/bin/sh
# push local ports tree changes
#
# Usage: push [-f]
#
# -f: force push (use 'git push --force')
#
# globals expected in ${HOME}/.ports.conf with sample values
# No leading '/' on directory names means they are relative to $HOME
# portsd='/usr/ports' # ports directory
# pullm=gsr # pull method
. "$HOME/.ports.conf"
# push predicate
pushp() {
local ret=-1
if [ "$pullm" != 'gsr' ]; then
printf "Pull method is not 'git svn rebase. Refusing to push.\\n'".
ret=1
else
case $askpushp in
[Nn][Oo]|0)
ret=0
;;
*)
while read -rp "Push changes (y/n)? " cont; do
case $cont in
[Yy]|[Yy][Ee][Ss])
ret=0
break
;;
[Nn]|[Nn][Oo])
ret=1
break
;;
*)
continue
;;
esac
done
esac
fi
return "$ret"
}
# push changes
push() {
case $pushp in
[Yy]|[Yy][Ee][Ss]|1)
if pushp; then
printf "* git -C ${portsd} push"
if [ "$forcep" = 'yes' ]; then
printf "--force\\n"
git -C "${portsd}" push --force
else
printf "\\n"
git -C "${portsd}" push
fi
fi
;;
esac
}
############################################ main
OPTIND=1
while getopts ":f" opt; do
case $opt in
f) forcep=yes ;;
*) printf "Ignoring invalid option: -%s.\\n" "$opt" ;;
esac
done
shift $((OPTIND-1))
push