Skip to content

Commit 198ad45

Browse files
committed
Fix remote branch deleted handling
1 parent 5e63ca3 commit 198ad45

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Editor/GitDiffWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,11 @@ public void DrawGitDiff(Vector2 size, HunkAction stageHunk, HunkAction unstageHu
294294
var fileStatus = status.Files.FirstOrDefault(x => x.FullProjectPath.Contains(currentFile));
295295
if (fileStatus != null && !fileStatus.IsUnresolved)
296296
{
297-
if (!staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), $"Stage", EditorStyles.miniButton))
297+
if (!staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), "Stage", EditorStyles.miniButton))
298298
stageHunk.Invoke(fileStatus, hunkIndex + 1);
299-
if (staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), $"Unstage", EditorStyles.miniButton))
299+
if (staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), "Unstage", EditorStyles.miniButton))
300300
unstageHunk.Invoke(fileStatus, hunkIndex + 1);
301-
if (!staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), $"Discard", EditorStyles.miniButton))
301+
if (!staged && GUI.Button(new Rect(verticalOffsest -= buttonWidth, currentOffset, 70, headerHeight), "Discard", EditorStyles.miniButton))
302302
discardHunk.Invoke(fileStatus, hunkIndex + 1);
303303
}
304304
}

Editor/Module.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,13 @@ async Task<RemoteStatus> GetRemoteStatus()
459459
string remoteAlias = (await DefaultRemote).Alias;
460460
var branches = await References;
461461
if (!branches.Any(x => x is RemoteBranch remoteBranch && remoteBranch.RemoteAlias == remoteAlias && remoteBranch.Name == currentBranch))
462-
return null;
462+
return new RemoteStatus(null, 0, 0, null);
463463
try
464464
{
465-
int ahead = int.Parse((await RunGit($"rev-list --count {remoteAlias}/{currentBranch}..{currentBranch}")).Output.Trim());
466-
int behind = int.Parse((await RunGit($"rev-list --count {currentBranch}..{remoteAlias}/{currentBranch}")).Output.Trim());
465+
var aheadResult = await RunGit($"rev-list --count {remoteAlias}/{currentBranch}..{currentBranch}", true);
466+
int ahead = aheadResult.ExitCode == 0 ? int.Parse(aheadResult.Output.Trim()) : 0;
467+
var behindResult = await RunGit($"rev-list --count {currentBranch}..{remoteAlias}/{currentBranch}", true);
468+
int behind = behindResult.ExitCode == 0 ? int.Parse(behindResult.Output.Trim()) : 0;
467469
return new RemoteStatus(remotes[0].Alias, ahead, behind, null);
468470
}
469471
catch (Exception e)

0 commit comments

Comments
 (0)