Update 1 file: functions.zsh
This commit is contained in:
@@ -15,19 +15,17 @@ dotstate_update() {
|
|||||||
local REPO_URL="https://git.jeremymcclure.com/jeremy/dotstate-storage.git"
|
local REPO_URL="https://git.jeremymcclure.com/jeremy/dotstate-storage.git"
|
||||||
local TARGET_DIR="$HOME/.config/dotstate/storage"
|
local TARGET_DIR="$HOME/.config/dotstate/storage"
|
||||||
|
|
||||||
if [[ -d "$TARGET_DIR/.git" ]]; then
|
[[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0
|
||||||
local remote_sha local_sha
|
[[ ! -d "$TARGET_DIR/.git" ]] && return 0
|
||||||
remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
|
|
||||||
[[ -z "$remote_sha" ]] && return 0
|
|
||||||
local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD)
|
|
||||||
[[ "$remote_sha" == "$local_sha" ]] && return 0
|
|
||||||
info "Repository out of date. Pulling updates..."
|
|
||||||
git -C "$TARGET_DIR" pull &>/dev/null
|
|
||||||
else
|
|
||||||
info "Repository not found. Cloning..."
|
|
||||||
git clone --depth=1 "$REPO_URL" "$TARGET_DIR" &>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
dotstate activate &>/dev/null
|
local remote_sha local_sha
|
||||||
|
remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
|
||||||
|
[[ -z "$remote_sha" ]] && return 0
|
||||||
|
local_sha=$(git -C "$TARGET_DIR" rev-parse HEAD)
|
||||||
|
[[ "$remote_sha" == "$local_sha" ]] && return 0
|
||||||
|
|
||||||
|
info "Repository out of date. Pulling updates..."
|
||||||
|
git -C "$TARGET_DIR" pull &>/dev/null
|
||||||
|
dotstate activate
|
||||||
exec zsh
|
exec zsh
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user