added script for half-automated cherry-picking all projects
authorRoland Haeder <roland@mxchange.org>
Wed, 1 Jun 2016 20:09:50 +0000 (22:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 1 Jun 2016 20:09:50 +0000 (22:09 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
cherry-jprojects.sh [new file with mode: 0755]

diff --git a/cherry-jprojects.sh b/cherry-jprojects.sh
new file mode 100755 (executable)
index 0000000..ef82bae
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+. ./.jprojects.sh || exit 255
+
+for project in ${LIST}; do
+       if [ "${project}" = "jprojects-scripts" ]
+       then
+               echo "$0: Skipping jprojects-scripts ..."
+               continue
+       elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
+       then
+               echo "$0: Project '${project}' does not exist."
+               continue
+       elif [ ! -f "${JPROJECTS_HOME}/${project}/.gitcommits" ]
+       then
+               # No .gitcommits file, skip this silently
+               continue
+       fi
+
+       COMMIT_IDS=`cat "${JPROJECTS_HOME}/${project}/.gitcommits"`
+       COMMITS_FILE="${JPROJECTS_HOME}/${project}/.gitcommits"
+
+       echo "$0: Cherry-picking on project '${project}' ..."
+       for commit in ${COMMIT_IDS}; do
+               cd "${JPROJECTS_HOME}/${project}"
+               echo "$0: Working on commit '${commit}' ..."
+               FOUND_ID=`git rev-list "${commit}" --max-count=1 2>&1`
+               STATUS="$?"
+
+               if [ "${STATUS}" != "0" ]
+               then
+                       echo "$0: Found invalid commit id '${commit}' or status '${STATUS}'."
+                       echo "$0: Maybe forgot git-remote add <project-name>-local <local-path> ?"
+                       exit 1
+               fi
+
+               git cherry-pick -S "${commit}" || exit 255
+
+               echo "$0: Removing commit from list ..."
+               REMAINING_IDS=`cat ${COMMITS_FILE} | grep -v "${commit}"`
+               echo "${REMAINING_IDS}" > ${COMMITS_FILE}
+       done
+
+       rm -f "${COMMITS_FILE}"
+done
+
+echo "$0: All done."
+exit 0