Initial commit
[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         echo "$0: Processing '${project}' ..."
16         cd "${JPROJECTS_HOME}/${project}"
17
18         CHECK_BRANCH=`git branch --all | grep "${NEW_BRANCH}"`
19         echo "$0: CHECK_BRANCH='${CHECK_BRANCH}'"
20
21         if [ -z "${CHECK_BRANCH}" ]
22         then
23                 echo "$0: Creating branch '${NEW_BRANCH}' ..."
24                 git checkout -b "${NEW_BRANCH}"
25         fi
26
27         if [ -n "${COMMIT_MESSAGE}" ]
28         then
29                 if [ -n "${COMMIT_ADD}" ]
30                 then
31                         echo "$0: Adding '${COMMIT_ADD}' ..."
32                         git add "${COMMIT_ADD}"
33                 fi
34
35                 echo "$0: Committing '${NEW_BRANCH}' ..."
36                 git commit -m "${COMMIT_MESSAGE}" --signoff -S -a
37         fi
38
39         if [ -n "${AFTER_COMMIT_BRANCH}" ]
40         then
41                 echo "$0: Switching in '${project}' to '${AFTER_COMMIT_BRANCH}' ..."
42                 git checkout "${AFTER_COMMIT_BRANCH}"
43         fi
44 done
45
46 echo "$0: All done."
47 exit 0