Some fixes:
[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 commit --signoff -S lib/*.jar -m "$1"
26                 elif [ -n "$1" -a -n "$2" ]
27                 then
28                         # Regular commit with given message
29                         git commit $2 --signoff -S -m "$1" || exit 255
30                 elif [ -n "$1" ]
31                 then
32                         # Regular commit with given message
33                         git commit -a --signoff -S -m "$1" || exit 255
34                 else
35                         # Regular commit, will open $EDITOR for commit message
36                         git commit -a --signoff -S || exit 255
37                 fi
38         else
39                 echo "$0: Nothing to commit for project '${project}'."
40         fi
41 done
42
43 echo "$0: All done."
44 exit 0