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

Show Rebase Progress (plus |REVERTING) #599

Merged
merged 4 commits into from
Jul 31, 2018
Merged
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
54 changes: 34 additions & 20 deletions src/GitUtils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -65,41 +65,51 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw
Invoke-Utf8ConsoleCommand {
dbg 'Finding branch' $sw
$r = ''; $b = ''; $c = ''
if (Test-Path $gitDir\rebase-merge\interactive) {
dbg 'Found rebase-merge\interactive' $sw
$r = '|REBASE-i'
$b = "$(Get-Content $gitDir\rebase-merge\head-name)"
}
elseif (Test-Path $gitDir\rebase-merge) {
$step = ''; $total = ''
if (Test-Path $gitDir/rebase-merge) {
dbg 'Found rebase-merge' $sw
$r = '|REBASE-m'
$b = "$(Get-Content $gitDir\rebase-merge\head-name)"
if (Test-Path $gitDir/rebase-merge/interactive) {
dbg 'Found rebase-merge/interactive' $sw
$r = '|REBASE-i'
}
else {
$r = '|REBASE-m'
}
$b = "$(Get-Content $gitDir/rebase-merge/head-name)"
$step = "$(Get-Content $gitDir/rebase-merge/msgnum)"
$total = "$(Get-Content $gitDir/rebase-merge/end)"
}
else {
if (Test-Path $gitDir\rebase-apply) {
if (Test-Path $gitDir/rebase-apply) {
dbg 'Found rebase-apply' $sw
if (Test-Path $gitDir\rebase-apply\rebasing) {
dbg 'Found rebase-apply\rebasing' $sw
$step = "$(Get-Content $gitDir/rebase-merge/next)"
$total = "$(Get-Content $gitDir/rebase-merge/last)"

if (Test-Path $gitDir/rebase-apply/rebasing) {
dbg 'Found rebase-apply/rebasing' $sw
$r = '|REBASE'
}
elseif (Test-Path $gitDir\rebase-apply\applying) {
dbg 'Found rebase-apply\applying' $sw
elseif (Test-Path $gitDir/rebase-apply/applying) {
dbg 'Found rebase-apply/applying' $sw
$r = '|AM'
}
else {
dbg 'Found rebase-apply' $sw
$r = '|AM/REBASE'
}
}
elseif (Test-Path $gitDir\MERGE_HEAD) {
elseif (Test-Path $gitDir/MERGE_HEAD) {
dbg 'Found MERGE_HEAD' $sw
$r = '|MERGING'
}
elseif (Test-Path $gitDir\CHERRY_PICK_HEAD) {
elseif (Test-Path $gitDir/CHERRY_PICK_HEAD) {
dbg 'Found CHERRY_PICK_HEAD' $sw
$r = '|CHERRY-PICKING'
}
elseif (Test-Path $gitDir\BISECT_LOG) {
elseif (Test-Path $gitDir/REVERT_HEAD) {
dbg 'Found REVERT_HEAD' $sw
$r = '|REVERTING'
}
elseif (Test-Path $gitDir/BISECT_LOG) {
dbg 'Found BISECT_LOG' $sw
$r = '|BISECTING'
}
Expand All @@ -120,9 +130,9 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw
dbg 'Falling back on parsing HEAD' $sw
$ref = $null

if (Test-Path $gitDir\HEAD) {
dbg 'Reading from .git\HEAD' $sw
$ref = Get-Content $gitDir\HEAD 2>$null
if (Test-Path $gitDir/HEAD) {
dbg 'Reading from .git/HEAD' $sw
$ref = Get-Content $gitDir/HEAD 2>$null
}
else {
dbg 'Trying rev-parse' $sw
Expand Down Expand Up @@ -153,6 +163,10 @@ function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw
}
}

if ($step -and $total) {
$r += " $step/$total"
}

"$c$($b -replace 'refs/heads/','')$r"
}
}
Expand Down