61ac979b0a8bab1170012342b7da088854332ddb
[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 [ "$1" = "updated dist.sh" ]
27                 then
28                         # Special commit ... (known shell script)
29                         git commit --signoff -S "dist.sh" -m "$1"
30                 elif [ -n "$1" -a -n "$2" ]
31                 then
32                         # Regular commit with given message
33                         git commit $2 --signoff -S -m "$1" || exit 255
34                 elif [ -n "$1" ]
35                 then
36                         # Regular commit with given message
37                         git commit -a --signoff -S -m "$1" || exit 255
38                 else
39                         # Regular commit, will open $EDITOR for commit message
40                         git commit -a --signoff -S || exit 255
41                 fi
42         else
43                 echo "$0: Nothing to commit for project '${project}'."
44         fi
45 done
46
47 echo "$0: All done."
48 exit 0