Files
arthur-os/bin/omarchy-update-branch
T
d2a4cc0c4d Add omarchy CLI (#5477)
* Add omarchy CLI

* Remove outdated or internal

* Add bash completions for command

* Add omarchy command documentation

* Add missing docs

* Correct to what's now right

* Fix tests

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
2026-05-01 17:40:22 +02:00

37 lines
825 B
Bash
Executable File

#!/bin/bash
# omarchy:summary=Switch Omarchy branches and update from the selected branch
# omarchy:args=<branch>
set -e
if (($# == 0)); then
echo "Usage: omarchy-update-branch [master|dev]"
exit 1
fi
branch="$1"
# Snapshot before switching branch
omarchy-snapshot create || (( $? == 127 ))
if ! git -C "$OMARCHY_PATH" diff --quiet || ! git -C "$OMARCHY_PATH" diff --cached --quiet; then
stashed=true
git -C "$OMARCHY_PATH" stash push -u -m "Autostash before switching to $branch"
else
stashed=false
fi
# Switch branches
git -C "$OMARCHY_PATH" switch "$branch"
# Reapply stash if we made one
if [[ $stashed == "true" ]]; then
if ! git -C "$OMARCHY_PATH" stash pop; then
echo "⚠️ Conflicts when applying stash — stash kept"
fi
fi
# Update the system from the new branch
omarchy-update-perform