]> git.mxchange.org Git - jprojects-scripts.git/blobdiff - cherry-jprojects.sh
Continued:
[jprojects-scripts.git] / cherry-jprojects.sh
index ef82bae60f5649a7906d298fbd3a1632edfa2401..c04438e7de0c2b80a15cb98d61333e9423869fd0 100755 (executable)
@@ -3,6 +3,8 @@
 . ./.jprojects.sh || exit 255
 
 for project in ${LIST}; do
 . ./.jprojects.sh || exit 255
 
 for project in ${LIST}; do
+       COMMITS_FILE="${JPROJECTS_HOME}/${project}/.gitcommits"
+
        if [ "${project}" = "jprojects-scripts" ]
        then
                echo "$0: Skipping jprojects-scripts ..."
        if [ "${project}" = "jprojects-scripts" ]
        then
                echo "$0: Skipping jprojects-scripts ..."
@@ -11,20 +13,30 @@ for project in ${LIST}; do
        then
                echo "$0: Project '${project}' does not exist."
                continue
        then
                echo "$0: Project '${project}' does not exist."
                continue
-       elif [ ! -f "${JPROJECTS_HOME}/${project}/.gitcommits" ]
+       elif [ ! -f "${COMMITS_FILE}" ]
        then
                # No .gitcommits file, skip this silently
                continue
        fi
 
        then
                # No .gitcommits file, skip this silently
                continue
        fi
 
-       COMMIT_IDS=`cat "${JPROJECTS_HOME}/${project}/.gitcommits"`
-       COMMITS_FILE="${JPROJECTS_HOME}/${project}/.gitcommits"
+       COMMIT_IDS=$(cat "${COMMITS_FILE}")
+
+       if [ -n "${COMMIT_IDS}" ]
+       then
+               cd "${JPROJECTS_HOME}/${project}"
+               echo "$0: Fetching all for project '${project}' ..."
+               git prune
+               git fetch --all
+       else
+               echo "$0: Nothing to cherry-pick for '${project}'."
+               rm "${COMMITS_FILE}"
+               continue
+       fi
 
        echo "$0: Cherry-picking on project '${project}' ..."
        for commit in ${COMMIT_IDS}; do
 
        echo "$0: Cherry-picking on project '${project}' ..."
        for commit in ${COMMIT_IDS}; do
-               cd "${JPROJECTS_HOME}/${project}"
                echo "$0: Working on commit '${commit}' ..."
                echo "$0: Working on commit '${commit}' ..."
-               FOUND_ID=`git rev-list "${commit}" --max-count=1 2>&1`
+               FOUND_ID=$(git rev-list "${commit}" --max-count=1 2>&1)
                STATUS="$?"
 
                if [ "${STATUS}" != "0" ]
                STATUS="$?"
 
                if [ "${STATUS}" != "0" ]
@@ -37,7 +49,7 @@ for project in ${LIST}; do
                git cherry-pick -S "${commit}" || exit 255
 
                echo "$0: Removing commit from list ..."
                git cherry-pick -S "${commit}" || exit 255
 
                echo "$0: Removing commit from list ..."
-               REMAINING_IDS=`cat ${COMMITS_FILE} | grep -v "${commit}"`
+               REMAINING_IDS=$(cat ${COMMITS_FILE} | grep -v "${commit}")
                echo "${REMAINING_IDS}" > ${COMMITS_FILE}
        done
 
                echo "${REMAINING_IDS}" > ${COMMITS_FILE}
        done