Ignored genfiles.properties + added new script:
[jprojects-scripts.git] / cherry-jprojects.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 for project in ${LIST}; do
6         COMMITS_FILE="${JPROJECTS_HOME}/${project}/.gitcommits"
7
8         if [ "${project}" = "jprojects-scripts" ]
9         then
10                 echo "$0: Skipping jprojects-scripts ..."
11                 continue
12         elif [ ! -d "${JPROJECTS_HOME}/${project}" ]
13         then
14                 echo "$0: Project '${project}' does not exist."
15                 continue
16         elif [ ! -f "${COMMITS_FILE}" ]
17         then
18                 # No .gitcommits file, skip this silently
19                 continue
20         fi
21
22         COMMIT_IDS=`cat "${COMMITS_FILE}"`
23
24         if [ -n "${COMMIT_IDS}" ]
25         then
26                 cd "${JPROJECTS_HOME}/${project}"
27                 echo "$0: Pulling all for project '${project}' ..."
28                 git pull --all
29         else
30                 echo "$0: Nothing to cherry-pick for '${project}'."
31                 rm "${COMMITS_FILE}"
32                 continue
33         fi
34
35         echo "$0: Cherry-picking on project '${project}' ..."
36         for commit in ${COMMIT_IDS}; do
37                 echo "$0: Working on commit '${commit}' ..."
38                 FOUND_ID=`git rev-list "${commit}" --max-count=1 2>&1`
39                 STATUS="$?"
40
41                 if [ "${STATUS}" != "0" ]
42                 then
43                         echo "$0: Found invalid commit id '${commit}' or status '${STATUS}'."
44                         echo "$0: Maybe forgot git-remote add <project-name>-local <local-path> ?"
45                         exit 1
46                 fi
47
48                 git cherry-pick -S "${commit}" || exit 255
49
50                 echo "$0: Removing commit from list ..."
51                 REMAINING_IDS=`cat ${COMMITS_FILE} | grep -v "${commit}"`
52                 echo "${REMAINING_IDS}" > ${COMMITS_FILE}
53         done
54
55         rm -f "${COMMITS_FILE}"
56 done
57
58 echo "$0: All done."
59 exit 0