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

fix(scoop-update): fix branch switching #3372

Merged
merged 6 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions lib/git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ function git_branch {
function git_config {
git_proxy_cmd config $args
}

function git_reset {
git_proxy_cmd reset $args
}
11 changes: 9 additions & 2 deletions libexec/scoop-update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,18 @@ function update_scoop() {
# Check if user configured other branch
$branch = $(get_config SCOOP_BRANCH)
if ((git_branch) -notlike "*$branch") {
chawyehsu marked this conversation as resolved.
Show resolved Hide resolved
git_fetch --all -q
# reset git fetch refs (GH-3368)
git_config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
# fetch remote branches
git_fetch --force origin -q
# checkou and track the branch
git_checkout -B $branch -q
chawyehsu marked this conversation as resolved.
Show resolved Hide resolved
# reset branch HEAD
git_reset --hard origin/$branch -q
} else {
git_pull -q
}

git_pull -q
$res = $lastexitcode
if($show_update_log) {
git_log --no-decorate --date=local --since="`"$last_update`"" --format="`"tformat: * %C(yellow)%h%Creset %<|(72,trunc)%s %C(cyan)%cr%Creset`"" HEAD
Expand Down