Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(scoop-update): Stash uncommitted changes before update #5091

Merged
merged 6 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## [Unreleased](/~https://github.com/ScoopInstaller/Scoop/compare/v0.2.4...develop)
## [Unreleased](/~https://github.com/ScoopInstaller/Scoop/compare/master...develop)

### Features

- **scoop-(un)hold:** Support `scoop (un)hold scoop` ([#5089](/~https://github.com/ScoopInstaller/Scoop/issues/5089))
- **scoop-update:** Stash uncommitted changes before update ([#5091](/~https://github.com/ScoopInstaller/Scoop/issues/5091))

## [v0.2.4](/~https://github.com/ScoopInstaller/Scoop/compare/v0.2.3...v0.2.4) - 2022-08-08

Expand Down
4 changes: 4 additions & 0 deletions libexec/scoop-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
# * An empty or unset value for proxy is equivalent to 'default' (with no username or password)
# * To bypass the system proxy and connect directly, use 'none' (with no username or password)
#
# autostash_on_conflict: $true|$false
# When a conflict is detected during updating, Scoop will auto-stash the uncommitted changes.
# (Default is $false, which will abort the update)
#
# default_architecture: 64bit|32bit
# Allow to configure preferred architecture for application installation.
# If not specified, architecture is determined be system.
Expand Down
11 changes: 11 additions & 0 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ function update_scoop($show_update_log) {
$isRepoChanged = !($currentRepo -match $configRepo)
$isBranchChanged = !($currentBranch -match "\*\s+$configBranch")

# Stash uncommitted changes
if (git -C "$currentdir" diff HEAD --name-only) {
if (get_config autostash_on_conflict) {
warn "Uncommitted changes detected. Stashing..."
git -C "$currentdir" stash push -m "WIP at $([System.DateTime]::Now.ToString('o'))" -u -q
} else {
warn "Uncommitted changes detected. Update aborted."
return
}
}

# Change remote url if the repo is changed
if ($isRepoChanged) {
git -C "$currentdir" config remote.origin.url "$configRepo"
Expand Down