Files
omarchy/bin/omarchy-update
Richard Macklin 4bb8afde02 Reset any stash changes before proceeding if there were conflicts
If the worktree has conflicts after applying the user's changes from the
autostash, we should reset them before proceeding to ensure we are in
a working state. When there are conflicts, git still keeps the stash
entry, so the user will still be able to manually re-pop the stash and
resolve the conflicts after `omarchy-update` has finished.

In the case of conflicts, the output will look something like this (I've
omitted most of the normal `git pull` output, hence the `[...]`):

```
Updating 729cd6a..45b5d3e
Created autostash: 91853c4
Fast-forward
 bin/omarchy                                                                |  10 +++++++---
 [...]
 create mode 100644 themes/tokyo-night/backgrounds/2--Milad-Fakurian-Abstract-Purple-Blue.jpg
Applying autostash resulted in conflicts.
Your changes are safe in the stash.
You can run "git stash pop" or "git stash drop" at any time.
bin/omarchy:65: leftover conflict marker
```

before proceeding with the rest of the `omarchy-update` script from a
clean state. So the user will see 1) that there were conflicts when
applying the autostashed changes, 2) that their changes are still safe
in the stash, and 3) which files (and lines) had conflict markers.
2025-07-17 23:06:25 -07:00

33 lines
729 B
Bash
Executable File

#!/bin/bash
cd ~/.local/share/omarchy
if [[ $1 == "all" ]]; then
# Run all migrations
last_updated_at=1
else
# Remember the version we're at before upgrading
last_updated_at=$(git log -1 --format=%cd --date=unix)
fi
# Get the latest while trying to preserve any modifications
git pull --autostash
git diff --check || git reset --merge
# Run any pending migrations
for file in migrations/*.sh; do
filename=$(basename "$file")
migrate_at="${filename%.sh}"
if [ $migrate_at -gt $last_updated_at ]; then
echo -e "\e[32m\nRunning migration ($migrate_at)\e[0m"
source $file
fi
done
# Back to where we came from
cd - >/dev/null
echo -e ""
gum confirm "Update system packages too?" && yay -Syu --noconfirm