Update source URLs, add --sync-urls flag/function

This commit is contained in:
Adam Goldsmith 2020-09-23 00:12:35 -04:00
parent 6ca107babf
commit 97b399681e

32
dup
View File

@ -2,8 +2,21 @@
set -eu set -eu
PULL_BASE="https://adamgoldsmith.name/cgit" PULL_BASE="https://git.adamgoldsmith.name"
PUSH_BASE="ag:/srv/git" DOTFILES_PULL_BASE="${PULL_BASE}/dotfiles"
BOOTSTRAP_URL="${PULL_BASE}/adam/bootstrap.git"
function sync_urls() {
cd "$(dirname ${BASH_SOURCE[0]})"
git remote set-url origin "$BOOTSTRAP_URL"
git remote set-url --push --delete origin '.*' || true
for dir in */
do
git -C "$dir" remote set-url origin "$DOTFILES_PULL_BASE/${dir%/}.git"
git -C "$dir" remote set-url --push --delete origin '.*' || true
done
}
function do_get() { function do_get() {
target="$1" target="$1"
@ -12,11 +25,7 @@ function do_get() {
echo "$target already exists, not getting" echo "$target already exists, not getting"
else else
echo "Getting $target" echo "Getting $target"
git clone "$PULL_BASE/dotfiles/$target.git" --recurse-submodules git clone "$DOTFILES_PULL_BASE/$target.git" --recurse-submodules
cd $target
git remote set-url origin "$PULL_BASE/dotfiles/$target.git"
git remote set-url --push origin "$PUSH_BASE/dotfiles/$target.git"
cd ..
fi fi
} }
@ -92,6 +101,10 @@ do
quiet=true quiet=true
shift shift
;; ;;
--sync-urls)
sync_urls
exit
;;
--) --)
shift shift
break break
@ -107,10 +120,9 @@ done
if [ "$bootstrap" = true ] if [ "$bootstrap" = true ]
then then
git clone "$PULL_BASE/bootstrap.git" .dotfiles git clone "$BOOTSTRAP_URL" .dotfiles
cd .dotfiles cd .dotfiles
git remote set-url origin "$PULL_BASE/bootstrap.git" git remote set-url origin "$BOOTSTRAP_URL"
git remote set-url --push origin "$PUSH_BASE/bootstrap.git"
else else
cd "$(dirname ${BASH_SOURCE[0]})" cd "$(dirname ${BASH_SOURCE[0]})"
fi fi