]> git.mxchange.org Git - jprojects-scripts.git/blob - commit-jprojects.sh
48ce900ff5bee48b3762047e7357e838cc0e5bf9
[jprojects-scripts.git] / commit-jprojects.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 for project in ${LIST}; do
6         if [ "${project}" = "jprojects-scripts" ]
7         then
8                 echo "$0: Skipping jprojects-scripts ..."
9                 continue
10         elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
11         then
12                 echo "$0: Project '${project}' does not exist."
13                 continue
14         fi
15
16         cd "${JPROJECTS_HOME}/${project}" || exit 255
17         CHECK_CHANGES=$(git commit -a --dry-run | grep "Changes to be committed:")
18
19         if [ -n "${CHECK_CHANGES}" ]
20         then
21                 echo "$0: Committing '${project}' ..."
22                 if [ "$1" = "updated jar(s)" ]
23                 then
24                         # Special commit ... (known-binaries)
25                         git add lib/ || exit 255
26                         git commit --signoff -S lib/*.jar -m "$1"
27                 elif [ "$1" = "updated dist.sh" ]
28                 then
29                         # Special commit ... (known shell script)
30                         git commit --signoff -S "dist.sh" -m "$1"
31                 elif [ -n "$1" -a -n "$2" ]
32                 then
33                         # Regular commit with given message
34                         git add $2 || exit 255
35                         git commit $2 --signoff -S -m "$1" || exit 255
36                 elif [ -d "$1" -o -f "$1" ]
37                 then
38                         # Limited commit with no message
39                         git add $1 || exit 255
40                         git commit $1 --signoff -S || exit 255
41                 elif [ -n "$1" ]
42                 then
43                         # Regular commit with given message
44                         git commit -a --signoff -S -m "$1" || exit 255
45                 else
46                         # Regular commit, will open $EDITOR for commit message
47                         git commit -a --signoff -S || exit 255
48                 fi
49         else
50                 echo "$0: Nothing to commit for project '${project}'."
51         fi
52 done
53
54 echo "$0: All done."
55 exit 0