Skip to content

Commit

Permalink
Merge pull request #599 from dahlbyk/rebase-progress
Browse files Browse the repository at this point in the history
Show Rebase Progress (plus |REVERTING)
  • Loading branch information
dahlbyk committed Jul 31, 2018
2 parents 836ec8c + e6b1e3e commit 2937861
Showing 1 changed file with 34 additions and 20 deletions.
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

0 comments on commit 2937861

Please sign in to comment.