mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-19 20:29:45 +01:00
feat(update): allow updating from branch set up on install
Closes #8788 Co-authored-by: Nikolas Garofil <nikolas@garofil.be>
This commit is contained in:
parent
7ded6752fd
commit
098bcda691
2 changed files with 37 additions and 22 deletions
|
@ -65,7 +65,7 @@ fmt_underline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt_code() {
|
fmt_code() {
|
||||||
# shellcheck disable=SC2016 # backtic in single-quote
|
# shellcheck disable=SC2016 # backtick in single-quote
|
||||||
printf '`\033[38;5;247m%s%s`\n' "$*" "$RESET"
|
printf '`\033[38;5;247m%s%s`\n' "$*" "$RESET"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,8 @@ setup_ohmyzsh() {
|
||||||
-c fsck.zeroPaddedFilemode=ignore \
|
-c fsck.zeroPaddedFilemode=ignore \
|
||||||
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
||||||
-c receive.fsck.zeroPaddedFilemode=ignore \
|
-c receive.fsck.zeroPaddedFilemode=ignore \
|
||||||
|
-c oh-my-zsh.remote=origin \
|
||||||
|
-c oh-my-zsh.branch="$BRANCH" \
|
||||||
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
|
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
|
||||||
fmt_error "git clone of oh-my-zsh repo failed"
|
fmt_error "git clone of oh-my-zsh repo failed"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -66,10 +66,20 @@ git config rebase.autoStash true
|
||||||
|
|
||||||
local ret=0
|
local ret=0
|
||||||
|
|
||||||
|
# repository settings
|
||||||
|
remote=${"$(git config --local oh-my-zsh.remote)":-origin}
|
||||||
|
branch=${"$(git config --local oh-my-zsh.branch)":-master}
|
||||||
|
|
||||||
|
# repository state
|
||||||
|
last_head=$(git symbolic-ref --quiet --short HEAD || git rev-parse HEAD)
|
||||||
|
# checkout update branch
|
||||||
|
git checkout -q "$branch" -- || exit 1
|
||||||
|
# branch commit before update (used in changelog)
|
||||||
|
last_commit=$(git rev-parse "$branch")
|
||||||
|
|
||||||
# Update Oh My Zsh
|
# Update Oh My Zsh
|
||||||
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
|
||||||
last_commit=$(git rev-parse HEAD)
|
if git pull --rebase --stat $remote $branch; then
|
||||||
if git pull --rebase --stat origin master; then
|
|
||||||
# Check if it was really updated or not
|
# Check if it was really updated or not
|
||||||
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
||||||
message="Oh My Zsh is already at the latest version."
|
message="Oh My Zsh is already at the latest version."
|
||||||
|
@ -103,6 +113,9 @@ else
|
||||||
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# go back to HEAD previous to update
|
||||||
|
git checkout -q "$last_head" --
|
||||||
|
|
||||||
# Unset git-config values set just for the upgrade
|
# Unset git-config values set just for the upgrade
|
||||||
case "$resetAutoStash" in
|
case "$resetAutoStash" in
|
||||||
"") git config --unset rebase.autoStash ;;
|
"") git config --unset rebase.autoStash ;;
|
||||||
|
|
Loading…
Reference in a new issue