Jepp, no more these projects
[jprojects-scripts.git] / create-jproject-branch.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 echo "$0: JPROJECTS_HOME='${JPROJECTS_HOME}'"
6
7 NEW_BRANCH="rewrites/wildfly"
8
9 #COMMIT_MESSAGE="WildFly branch created with initial scripts, but it doesn't load my libs."
10 COMMIT_MESSAGE=""
11 COMMIT_ADD=""
12 AFTER_COMMIT_BRANCH="master"
13
14 for project in ${LIST}; do
15         if [ "${project}" = "jprojects-scripts" ]
16         then
17                 echo "$0: Skipping jprojects-scripts ..."
18                 continue
19         elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
20         then
21                 echo "$0: Project '${project}' does not exist."
22                 continue
23         fi
24
25         echo "$0: Processing '${project}' ..."
26         cd "${JPROJECTS_HOME}/${project}"
27
28         CHECK_BRANCH=`git branch --all | grep "${NEW_BRANCH}"`
29         echo "$0: CHECK_BRANCH='${CHECK_BRANCH}'"
30
31         if [ -z "${CHECK_BRANCH}" ]
32         then
33                 echo "$0: Creating branch '${NEW_BRANCH}' ..."
34                 git checkout -b "${NEW_BRANCH}"
35         fi
36
37         if [ -n "${COMMIT_MESSAGE}" ]
38         then
39                 if [ -n "${COMMIT_ADD}" ]
40                 then
41                         echo "$0: Adding '${COMMIT_ADD}' ..."
42                         git add "${COMMIT_ADD}"
43                 fi
44
45                 echo "$0: Committing '${NEW_BRANCH}' ..."
46                 git commit -m "${COMMIT_MESSAGE}" --signoff -S -a
47         fi
48
49         if [ -n "${AFTER_COMMIT_BRANCH}" ]
50         then
51                 echo "$0: Switching in '${project}' to '${AFTER_COMMIT_BRANCH}' ..."
52                 git checkout "${AFTER_COMMIT_BRANCH}"
53         fi
54 done
55
56 echo "$0: All done."
57 exit 0