[cros] update remote url

This commit is contained in:
z4yx 2020-05-15 12:35:32 +08:00
parent 502675f941
commit 7c1a102e1d

12
cros.sh
View File

@ -23,15 +23,17 @@ function git_clone_or_pull {
name=$(basename $2)
if [[ -z $BARE ]]; then
if [[ -d $DIRECTORY ]]; then
git -C $DIRECTORY pull
git -C "$DIRECTORY" remote set-url origin "$URL"
git -C "$DIRECTORY" pull
else
git clone $URL $DIRECTORY
git clone "$URL" "$DIRECTORY"
fi
else
if [[ -d $DIRECTORY ]]; then
git -C $DIRECTORY fetch --force --prune 2>&1 | sed "s/^/$name: /"
if [[ -d "$DIRECTORY" ]]; then
git -C "$DIRECTORY" remote set-url origin "$URL"
git -C "$DIRECTORY" fetch --force --prune 2>&1 | sed "s/^/$name: /"
else
git clone --bare $URL $DIRECTORY
git clone --bare "$URL" "$DIRECTORY"
fi
fi
}