Skip to content

Commit 9c93c8e

Browse files
committed
feat: refactor git commands to use CAULDRON_PATH for better path handling
1 parent 5466e14 commit 9c93c8e

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

update/cauldron_update.fish

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,13 @@ function cauldron_update -d 'Update Cauldron to the latest version'
157157
return 1
158158
end
159159

160-
cd "$CAULDRON_PATH"
161-
162160
# Fetch latest changes
163161
echo "→ Checking for updates on branch '$branch'..."
164-
git fetch origin $branch 2>/dev/null
162+
git -C "$CAULDRON_PATH" fetch origin $branch 2>/dev/null
165163

166164
# Check if updates are available
167-
set -l local_hash (git rev-parse HEAD)
168-
set -l remote_hash (git rev-parse origin/$branch 2>/dev/null)
165+
set -l local_hash (git -C "$CAULDRON_PATH" rev-parse HEAD)
166+
set -l remote_hash (git -C "$CAULDRON_PATH" rev-parse origin/$branch 2>/dev/null)
169167

170168
if test "$local_hash" = "$remote_hash"
171169
echo "✓ Cauldron is already up to date!"
@@ -176,7 +174,7 @@ function cauldron_update -d 'Update Cauldron to the latest version'
176174
echo ""
177175
echo "Updates available:"
178176
echo ""
179-
git log --oneline --decorate --graph HEAD..origin/$branch | head -n 10
177+
git -C "$CAULDRON_PATH" log --oneline --decorate --graph HEAD..origin/$branch | head -n 10
180178

181179
if set -q _flag_check_only
182180
echo ""
@@ -212,11 +210,11 @@ function cauldron_update -d 'Update Cauldron to the latest version'
212210

213211
# Stash local changes
214212
echo "→ Stashing local changes..."
215-
git stash push -m "Cauldron auto-update stash (date +%Y%m%d_%H%M%S)" 2>/dev/null
213+
git -C "$CAULDRON_PATH" stash push -m "Cauldron auto-update stash (date +%Y%m%d_%H%M%S)" 2>/dev/null
216214

217215
# Pull updates
218216
echo "→ Pulling latest changes..."
219-
if not git pull origin $branch --rebase
217+
if not git -C "$CAULDRON_PATH" pull origin $branch --rebase
220218
echo "Error: Failed to pull updates"
221219
echo "Your local changes have been stashed"
222220
echo "Run 'cd $CAULDRON_PATH && git stash pop' to restore them"

0 commit comments

Comments
 (0)