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