1 |
#! /bin/sh |
2 |
|
3 |
version="1.0.0" |
4 |
me=git-sync |
5 |
|
6 |
show_help() { |
7 |
echo "Usage: git sync [options] [args]..." |
8 |
echo " $me [options] [args]..." |
9 |
echo "" |
10 |
echo "Synchronize local changes with remote and vise-versa." |
11 |
echo "" |
12 |
echo "Options:" |
13 |
echo " --help Show this help and exit" |
14 |
echo " --version Output version information and exit" |
15 |
echo "" |
16 |
echo "Bug reports and questions should be sent to <[email protected]>." |
17 |
} |
18 |
|
19 |
show_version() { |
20 |
cat <<EOF |
21 |
$me (OSN Commons) v$version |
22 |
|
23 |
This program is free software: you can redistribute it and/or modify |
24 |
it under the terms of the GNU General Public License as published by |
25 |
the Free Software Foundation, either version 3 of the License, or |
26 |
(at your option) any later version. |
27 |
|
28 |
Written by Ar Rakin. |
29 |
EOF |
30 |
} |
31 |
|
32 |
for arg in "$@"; do |
33 |
case "$arg" in |
34 |
--help) |
35 |
show_help |
36 |
exit 0 |
37 |
;; |
38 |
|
39 |
--version) |
40 |
show_version |
41 |
exit 0 |
42 |
;; |
43 |
esac |
44 |
done |
45 |
|
46 |
git pull $@ |
47 |
|
48 |
code="$?" |
49 |
|
50 |
if [ "$code" -ne 0 ]; then |
51 |
exit "$code" |
52 |
fi |
53 |
|
54 |
git push $@ |
55 |
exit $? |