aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2018-07-18 16:18:53 +0530
committerDaniel Lezcano <daniel.lezcano@linaro.org>2018-08-29 12:06:12 +0200
commit1a290bc9b7ed9fd19403961eacf95aa0c1d1ad10 (patch)
tree2760885b26df746a91f632609e4aea5502d1cb6e
parent4405a9c7a077de3aa567642f2c4c556f1492277f (diff)
ci-merge: Clone rr-cache into .automerge
Instead of creating an abundance of directories in /tmp, clone the rr-cache into .automerge/rr-cache and symlink it into .git/rr-cache. After running ci-merge a new commit is created in the rr-cache git, which for now needs to be pushed manually to the shared rerere cache. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> [Manually applied the patch to master] Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rwxr-xr-xci-merge39
1 files changed, 24 insertions, 15 deletions
diff --git a/ci-merge b/ci-merge
index 05516d7..1bcd904 100755
--- a/ci-merge
+++ b/ci-merge
@@ -105,10 +105,7 @@ TRACK=tag
# Global cache of rerere resolutions
RERERE_CACHE=""
-# Temporary directory to clone the rerere cache into
-# This directory is not deleted at the end to allow for new merge resolutions to
-# be pushed to git
-TMP_DIR=$(mktemp -d --suffix -automerge.rerere)
+RERERE_CACHE_DIR=""
# Global variable to test if a change occured during the last merge
# or not. If one branch is added, deleted or updated, this variable
@@ -260,18 +257,35 @@ git_rerere_setup() {
# we enable the rerere option
echo "Reuse-Recorded-Resolution: Enabled"
- git clone -q --depth=1 $RERERE_CACHE $TMP_DIR
- if [ $? -ne 0 ]; then
- echo "WARNING: Unable to get shared rerere cache"
- return 1
+ if [ -e ".git/rr-cache" -a \! -L ".git/rr-cache" ]; then
+ echo "${TMP_DIR} already exists but isn't a symlink"
+ return 0
+ fi
+
+ RERERE_CACHE_DIR=".automerge/rr-cache"
+ if [ -d ${RERERE_CACHE_DIR} ]; then
+ (cd ${RERERE_CACHE_DIR} && git fetch && git reset --hard origin/master)
+ else
+ mkdir -p ".automerge"
+ git clone -q $RERERE_CACHE $RERERE_CACHE_DIR
+ ln -sfT ../${RERERE_CACHE_DIR}/rr-cache .git/rr-cache
fi
- $(cd $LOCAL_REPO/.git && git archive --remote=$TMP_DIR HEAD | tar xf -)
echo "Downloaded shared rerere cache"
return 0
}
+git_rerere_update() {
+ if [ -n "${RERERE_CACHE_DIR}" ]; then
+ if [[ $(cd ${RERERE_CACHE_DIR} && git status --porcelain) ]]; then
+ (cd ${RERERE_CACHE_DIR} &&
+ git add -A &&
+ git commit --no-edit -s -m 'New rr-cache entries from ci-merge')
+ fi
+ fi
+}
+
######################################################################
#
# Use appropriate terminal
@@ -673,9 +687,4 @@ if [ ! -z $REMOTE_REPO ]; then
fi
fi
-echo -n "Copy any new merge conflict resolutions to the rerere cache ($TMP_DIR) [Y/n]? "
-read RES
-if [ "${RES,,}" == "y" -o "$RES" == "" ]; then
- $(cd $LOCAL_REPO/.git && cp -a rr-cache $TMP_DIR)
- echo "Please make sure to _push_ any new conflict resolutions in $TMP_DIR manually to $RERERE_CACHE"
-fi
+git_rerere_update