Show the window before slow location probes and wrap git.exe for commit, diff, and merge.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -438,3 +438,88 @@ public class FileClassifierTests
|
||||
private static FileCategory Classify(string name, bool isDirectory = false, bool isRepoRoot = false)
|
||||
=> FileClassifier.Classify(name, @"C:\Downloads\" + name, isDirectory, isDirectory ? AttributeFlags.Directory : 0, isRepoRoot).Category;
|
||||
}
|
||||
|
||||
public class GitChangeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Rename_and_delete_labels()
|
||||
{
|
||||
var renamed = new GitChange
|
||||
{
|
||||
Path = "new.txt",
|
||||
OriginalPath = "old.txt",
|
||||
Index = 'R',
|
||||
WorkTree = '.',
|
||||
State = GitChangeState.Staged
|
||||
};
|
||||
Assert.Equal("old.txt → new.txt", renamed.DisplayPath);
|
||||
Assert.Equal("renamed", renamed.ChangeLabel);
|
||||
Assert.Equal(@"C:\src\new.txt", renamed.ToFullPath(@"C:\src"));
|
||||
Assert.False(renamed.IsDeleted);
|
||||
|
||||
var deleted = new GitChange
|
||||
{
|
||||
Path = "gone.txt",
|
||||
Index = '.',
|
||||
WorkTree = 'D',
|
||||
State = GitChangeState.Unstaged
|
||||
};
|
||||
Assert.True(deleted.IsDeleted);
|
||||
Assert.Equal("deleted", deleted.ChangeLabel);
|
||||
}
|
||||
}
|
||||
|
||||
public class BoundedWaitTests
|
||||
{
|
||||
[Fact]
|
||||
public void Try_returns_the_result_when_work_finishes()
|
||||
=> Assert.True(BoundedWait.Try(() => true, TimeSpan.FromSeconds(1)));
|
||||
|
||||
[Fact]
|
||||
public void Try_returns_false_when_work_exceeds_the_timeout()
|
||||
=> Assert.False(BoundedWait.Try(
|
||||
() =>
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
return true;
|
||||
},
|
||||
TimeSpan.FromMilliseconds(30)));
|
||||
}
|
||||
|
||||
public class GitCommandResultTests
|
||||
{
|
||||
[Fact]
|
||||
public void Display_prefers_summary_then_stderr_on_failure()
|
||||
{
|
||||
Assert.Equal("Committed.", GitCommandResult.Ok("Committed.").DisplayMessage);
|
||||
Assert.Equal(
|
||||
"not a fast-forward",
|
||||
new GitCommandResult
|
||||
{
|
||||
Succeeded = false,
|
||||
ExitCode = 1,
|
||||
StandardError = "not a fast-forward\n"
|
||||
}.DisplayMessage);
|
||||
Assert.Equal("git failed (exit 128).", new GitCommandResult
|
||||
{
|
||||
Succeeded = false,
|
||||
ExitCode = 128
|
||||
}.DisplayMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public class GitStatusBadgeTests
|
||||
{
|
||||
[Fact]
|
||||
public void Includes_merging_instead_of_clean()
|
||||
{
|
||||
var status = new GitStatus
|
||||
{
|
||||
RepoRoot = @"C:\src",
|
||||
Branch = "main",
|
||||
Operation = GitOperationKind.Merge
|
||||
};
|
||||
Assert.Equal("main · merging", status.Badge);
|
||||
Assert.Equal("merging", status.OperationLabel);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user