aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2021-02-19 19:12:25 +0100
committerDaniel Lezcano <daniel.lezcano@linaro.org>2021-02-22 09:29:04 +0100
commit2c0a8311f9741ce209722499b6af47925319f916 (patch)
tree05e81abe9986b19d73f071d91f2d6a7e931db284
parent7ed65dac7d4e082351ea1145534b6af69e4c3fcc (diff)
ci-merge: properly filter out remotes from local tree
The purpose of this function is to remove remotes from the local trees if they have been removed from the config file. It is broken since 2ebf50e36955 (ci-merge: Add missing -q to grep when searching for old branches). When we have -q everywhere like: echo $LINE | grep -q "^$REMOTE_NAME\b" | grep -q $REMOTE_URL | grep -q "$REMOTE_BRANCH" Then it will *always* be false, since the first grep command will return an empty string. What we really wanted to do is to find a remote in the local tree which is *not* in the config, so that we can simply remove it. We don't even need to look/match for branches, e.g. if we have a remote with the same name and the same url, then it's found, and we can keep it in case it's in the config file. Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rwxr-xr-xci-merge5
1 files changed, 2 insertions, 3 deletions
diff --git a/ci-merge b/ci-merge
index b95c760..7704f5b 100755
--- a/ci-merge
+++ b/ci-merge
@@ -434,7 +434,6 @@ do_remove_old() {
for REMOTE_NAME in $(git remote); do
- REMOTE_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref --remotes=$REMOTE_NAME | cut -d'/' -f1 --complement)
REMOTE_URL=$(git remote get-url $REMOTE_NAME)
FOUND=0
@@ -443,7 +442,7 @@ do_remove_old() {
# ignore commented lines
echo $LINE | egrep -q '(^#|^\s*$|^\s*\t*#)' && continue
- echo $LINE | grep -q "^$REMOTE_NAME\b" | grep -q $REMOTE_URL | grep -q "$REMOTE_BRANCH"
+ echo $LINE | grep "^$REMOTE_NAME\b" | grep -q $REMOTE_URL
if [ $? -eq 0 ]; then
FOUND=1
fi
@@ -458,7 +457,7 @@ do_remove_old() {
exit 1
fi
- echo "The remote $REMOTE_NAME $REMOTE_URL $REMOTE_BRANCH is no longer tracked."
+ echo "The remote $REMOTE_NAME $REMOTE_URL is no longer tracked."
echo -n "Delete it [Y/n]? "
read RES
if [ "$RES" == "Y" -o "$RES" == "y" -o "$RES" == "" ]; then