Skip to content

Commit bc19673

Browse files
committed
refactor: use a single git status process to query repository status in Welcome page
Signed-off-by: leo <longshuang@msn.cn>
1 parent 9071940 commit bc19673

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

‎src/Commands/QueryRepositoryStatus.cs‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public QueryRepositoryStatus(string repo)
1717

1818
public async Task<Models.RepositoryStatus> GetResultAsync()
1919
{
20-
Args = "status --porcelain=v2 -b";
20+
Args = "status --porcelain=v2 -b -uall --ignore-submodules=dirty";
2121
var rs = await ReadToEndAsync().ConfigureAwait(false);
2222
if (!rs.IsSuccess)
2323
return null;
@@ -36,12 +36,17 @@ public QueryRepositoryStatus(string repo)
3636
else
3737
status.CurrentBranch = head;
3838

39-
if (count == 4 && lines[3].StartsWith("# branch.ab ", StringComparison.Ordinal))
40-
ParseTrackStatus(status, lines[3].Substring(12).Trim());
39+
if (count >= 4)
40+
{
41+
var changesCount = count - 3;
42+
if (lines[3].StartsWith("# branch.ab ", StringComparison.Ordinal))
43+
{
44+
ParseTrackStatus(status, lines[3].Substring(12).Trim());
45+
changesCount--;
46+
}
4147

42-
status.LocalChanges = await new CountLocalChanges(WorkingDirectory, true) { RaiseError = false }
43-
.GetResultAsync()
44-
.ConfigureAwait(false);
48+
status.LocalChanges = changesCount;
49+
}
4550

4651
return status;
4752
}

0 commit comments

Comments
 (0)