Skip to content
Snippets Groups Projects

Make lb-use overwrite the current remote if necessary

Closed Igor Babuschkin requested to merge ibabusch/LbScripts:master into master
+ 13
1
Compare changes
  • Side-by-side
  • Inline
@@ -14,9 +14,21 @@ fi
if [ -z "$url" ] ; then
url=https://:@gitlab.cern.ch:8443/LHCb-SVN-mirrors/$name.git
fi
echo "calling: git remote add -f '$name' '$url'"
# define a remote "$name", overwrite it if it already exists
output=$(git remote add "$name" "$url" 2>&1)
if [ $? -eq 128 ]; then
    • Two questions:

      • would it not be better to do $? -ne 0?
      • what about
        if git remote | grep -q "^${name}\$" ; then
            git remote rm "$name"
        fi
        git remote add "$name" "$url"
        ?
      • I thought that the 128 return code was specific to this error. Will check up on that. (Catching the exact error would have the benefit of forwarding the other ones). Grepping for the name is probably better as well.

      • Please register or sign in to reply
Please register or sign in to reply
# A remote with that name exists
git remote rm "$name"
git remote add "$name" "$url"
echo "warning: existing remote '$name' overwritten'"
else
>&2 echo -n $output
fi
set -e
git remote add "$name" "$url"
git config "remote.${name}.tagopt" --no-tags
git config --add "remote.${name}.fetch" "+refs/tags/*:refs/tags/${name}/*"
git fetch "${name}"
Loading