155 references to GitCommandMode
aspire (50)
Configuration\ConfigSourceService.cs (9)
746
var json = await git.ReadBlobAsync(repositoryDirectory, version,
GitCommandMode
.Interactive, timeout.Token);
817
var
mode = allowInteractive ?
GitCommandMode
.Interactive :
GitCommandMode
.Unattended;
832
resolvedCommit.Length == 64 ? "sha256" : "sha1",
GitCommandMode
.Interactive, cancellationToken);
837
allowInteractive ?
GitCommandMode
.Interactive :
GitCommandMode
.Unattended, cancellationToken);
838
var commit = await client.GetCommitAsync(repositoryDirectory, "FETCH_HEAD^{commit}",
GitCommandMode
.Interactive, cancellationToken);
839
var entry = await client.GetFileAsync(repositoryDirectory, commit, source.Path,
GitCommandMode
.Interactive, cancellationToken);
Git\GitClient.cs (9)
20
public async Task<string> ResolveReferenceAsync(string repository, string? reference, DirectoryInfo workingDirectory,
GitCommandMode
mode, CancellationToken cancellationToken)
60
public Task InitializeAsync(DirectoryInfo workingDirectory, GitRepositoryLocation repository, string? objectFormat,
GitCommandMode
mode, CancellationToken cancellationToken)
76
public Task FetchAsync(GitRepositoryLocation destination, string repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken) =>
79
public Task CheckoutAsync(GitRepositoryLocation repository,
GitCommandMode
mode, CancellationToken cancellationToken) =>
82
public async Task<string> GetCommitAsync(GitRepositoryLocation repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken) =>
85
public async Task<GitTreeEntry?> GetFileAsync(GitRepositoryLocation repository, string commit, string path,
GitCommandMode
mode, CancellationToken cancellationToken)
97
public async Task<long?> GetObjectSizeAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken)
103
public Task<string> ReadBlobAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken) =>
106
private Task<string> RunAsync(GitRepositoryLocation repository, string[] arguments,
GitCommandMode
mode, CancellationToken cancellationToken)
Git\GitCommandRunner.cs (19)
17
Task<string> RunAsync(DirectoryInfo workingDirectory, string[] arguments,
GitCommandMode
mode, CancellationToken cancellationToken);
42
public async Task<string> RunAsync(DirectoryInfo workingDirectory, string[] arguments,
GitCommandMode
mode, CancellationToken cancellationToken)
51
return await RunProcessAsync(startInfo, captureCancellationOutput: command is "fetch" or "ls-remote" && mode !=
GitCommandMode
.Captured && startInfo.RedirectStandardOutput,
55
private bool IsUnattended(
GitCommandMode
mode) =>
56
mode ==
GitCommandMode
.Unattended || mode ==
GitCommandMode
.Interactive && !hostEnvironment.SupportsInteractiveInput;
58
internal ProcessStartInfo CreateStartInfo(string directory, string[] arguments,
GitCommandMode
mode)
60
var interactive = mode ==
GitCommandMode
.Interactive && hostEnvironment.SupportsInteractiveInput;
72
RedirectStandardInput = mode ==
GitCommandMode
.Captured || unattended,
81
if (!interactive && mode !=
GitCommandMode
.Captured)
109
var query = CreateStartInfo(source.WorkingDirectory, arguments,
GitCommandMode
.Unattended);
133
var repository = (await RunProcessAsync(urlQuery, captureCancellationOutput: false,
GitCommandMode
.Unattended, cancellationToken)).TrimEnd('\r', '\n');
148
command = (await RunProcessAsync(configQuery, captureCancellationOutput: false,
GitCommandMode
.Unattended, cancellationToken)).TrimEnd('\0');
253
childPath = await RunProcessAsync(pathQuery, captureCancellationOutput: false,
GitCommandMode
.Unattended, cancellationToken);
330
internal static void FilterEnvironment(IDictionary<string, string?> environment,
GitCommandMode
mode)
332
if (mode !=
GitCommandMode
.Captured)
351
internal async Task<string> RunProcessAsync(ProcessStartInfo startInfo, bool captureCancellationOutput,
GitCommandMode
mode, CancellationToken cancellationToken)
432
internal static GitCommandException CreateCommandException(string stderr, int exitCode,
GitCommandMode
mode)
437
|| (mode ==
GitCommandMode
.Captured && stderr.Contains("could not read Password", StringComparison.OrdinalIgnoreCase));
Git\IGitClient.cs (8)
9
Task<string> ResolveReferenceAsync(string repository, string? reference, DirectoryInfo workingDirectory,
GitCommandMode
mode, CancellationToken cancellationToken);
10
Task InitializeAsync(DirectoryInfo workingDirectory, GitRepositoryLocation repository, string? objectFormat,
GitCommandMode
mode, CancellationToken cancellationToken);
11
Task FetchAsync(GitRepositoryLocation destination, string repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken);
12
Task CheckoutAsync(GitRepositoryLocation repository,
GitCommandMode
mode, CancellationToken cancellationToken);
13
Task<string> GetCommitAsync(GitRepositoryLocation repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken);
14
Task<GitTreeEntry?> GetFileAsync(GitRepositoryLocation repository, string commit, string path,
GitCommandMode
mode, CancellationToken cancellationToken);
15
Task<long?> GetObjectSizeAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken);
16
Task<string> ReadBlobAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken);
Templating\TemplateEngineFactory.cs (5)
157
token => git.ResolveReferenceAsync(repository, reference, executionContext.WorkingDirectory,
GitCommandMode
.Captured, token), cancellationToken);
231
commitSha.Length == 64 ? "sha256" : "sha1",
GitCommandMode
.Captured, token);
232
await git.FetchAsync(location, repository, commitSha,
GitCommandMode
.Captured, token);
233
await git.CheckoutAsync(location,
GitCommandMode
.Captured, token);
234
var actualSha = await git.GetCommitAsync(location, "HEAD",
GitCommandMode
.Captured, token);
Aspire.Cli.Tests (105)
Commands\NewCommandLocalTemplateTests.cs (1)
1477
Assert.All(gitCommands.Commands, command => Assert.Equal(
GitCommandMode
.Captured, command.Mode));
Commands\NewCommandLocalTemplateTests.SourceList.cs (2)
252
Assert.Equal(includeInherited ? [json ?
GitCommandMode
.Unattended :
GitCommandMode
.Interactive] : [], git.FetchModes);
Commands\NewCommandLocalTemplateTests.SourceListGit.cs (5)
130
var
mode = json ?
GitCommandMode
.Unattended :
GitCommandMode
.Interactive;
329
var commit = await runner.RunAsync(repository, ["rev-parse", source.Ref!],
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
330
var version = await runner.RunAsync(repository, ["rev-parse", $"{source.Ref}:{source.Path}"],
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
Configuration\ConfigSourceServiceGitTests.cs (10)
231
startInfo, captureTimeoutOutput,
GitCommandMode
.Unattended, cancellation.Token);
294
var startInfo = client.CreateStartInfo(workspace.Path, ["fetch"],
GitCommandMode
.Unattended);
319
var startInfo = client.CreateStartInfo(workspace.Path, ["fetch", "--depth", "1", "--", "https://example.com/configuration", "HEAD"],
GitCommandMode
.Interactive);
344
var startInfo = runner.CreateStartInfo(workspace.Path, ["ls-remote", "--", "repository", "HEAD"],
GitCommandMode
.Interactive);
363
var startInfo = client.CreateStartInfo(workspace.Path, [command],
GitCommandMode
.Interactive);
715
GitCommandMode
[] expectedResolutionModes = selector == "commit" ? []
716
: [
GitCommandMode
.Interactive,
GitCommandMode
.Unattended,
GitCommandMode
.Interactive,
GitCommandMode
.Unattended];
Git\GitClientTests.cs (20)
31
var resolved = await client.ResolveReferenceAsync("-repository with spaces", reference, workspace.WorkspaceRoot,
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
41
Assert.Equal(
GitCommandMode
.Captured, command.Mode);
55
await client.ResolveReferenceAsync("repository", "same", workspace.WorkspaceRoot,
GitCommandMode
.Captured, TestContext.Current.CancellationToken));
59
[InlineData(nameof(
GitCommandMode
.Captured), 40)]
60
[InlineData(nameof(
GitCommandMode
.Interactive), 64)]
61
[InlineData(nameof(
GitCommandMode
.Unattended), 64)]
68
var
interactionMode = Enum.Parse<
GitCommandMode
>(mode);
88
client.ResolveReferenceAsync("repository", "missing", workspace.WorkspaceRoot,
GitCommandMode
.Captured, TestContext.Current.CancellationToken));
102
var resolved = await client.ResolveReferenceAsync("repository", new string('A', length), workspace.WorkspaceRoot,
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
117
await client.InitializeAsync(workspace.WorkspaceRoot, repository, objectFormat: null,
GitCommandMode
.Interactive, token);
118
await client.FetchAsync(repository, "repository with spaces", "refs/heads/main",
GitCommandMode
.Unattended, token);
119
Assert.Equal(TestGitCommandRunner.DefaultCommitSha, await client.GetCommitAsync(repository, "FETCH_HEAD^{commit}",
GitCommandMode
.Interactive, token));
126
Assert.Equal(
GitCommandMode
.Interactive, command.Mode);
132
Assert.Equal(
GitCommandMode
.Unattended, command.Mode);
137
Assert.Equal(
GitCommandMode
.Interactive, command.Mode);
155
var entry = await client.GetFileAsync(repository, objectId, path,
GitCommandMode
.Interactive, TestContext.Current.CancellationToken);
173
Assert.Null(await client.GetFileAsync(repository, TestGitCommandRunner.DefaultCommitSha, "file",
GitCommandMode
.Interactive, TestContext.Current.CancellationToken));
189
Assert.Equal(23, await client.GetObjectSizeAsync(repository, objectId,
GitCommandMode
.Interactive, TestContext.Current.CancellationToken));
190
Assert.Equal(content, await client.ReadBlobAsync(repository, objectId,
GitCommandMode
.Interactive, TestContext.Current.CancellationToken));
Git\GitCommandRunnerTests.Authentication.cs (18)
17
[InlineData(nameof(
GitCommandMode
.Unattended), true, true)]
18
[InlineData(nameof(
GitCommandMode
.Interactive), false, true)]
19
[InlineData(nameof(
GitCommandMode
.Interactive), true, false)]
20
[InlineData(nameof(
GitCommandMode
.Captured), false, false)]
26
var info = runner.CreateStartInfo(Environment.CurrentDirectory, ["ls-remote", "--", "repository"], Enum.Parse<
GitCommandMode
>(mode));
37
Assert.Equal(disabled || mode == nameof(
GitCommandMode
.Captured), info.RedirectStandardInput);
64
var
mode = unattended ?
GitCommandMode
.Unattended :
GitCommandMode
.Captured;
112
var info = runner.CreateStartInfo(workspace.Path, ["ls-remote", "--", server.Repository],
GitCommandMode
.Unattended);
119
runner.RunProcessAsync(info, captureCancellationOutput: false,
GitCommandMode
.Unattended, cancellation.Token));
181
var info = runner.CreateStartInfo(workspace.Path, arguments,
GitCommandMode
.Unattended);
218
var info = runner.CreateStartInfo(workspace.Path, arguments,
GitCommandMode
.Unattended);
285
var info = runner.CreateStartInfo(directory.FullName, arguments,
GitCommandMode
.Unattended);
308
var info = runner.CreateStartInfo(workspace.Path, arguments,
GitCommandMode
.Unattended);
335
var info = runner.CreateStartInfo(workspace.Path, arguments,
GitCommandMode
.Unattended);
394
["-c", $"alias.aspire-test-ssh={selection}", "aspire-test-ssh"],
GitCommandMode
.Unattended);
402
GitCommandMode
.Unattended, TestContext.Current.CancellationToken)).TrimEnd('\r', '\n');
Git\GitCommandRunnerTests.cs (33)
32
["fetch", "--", "-repository with spaces", "HEAD"],
GitCommandMode
.Captured);
65
GitCommandRunner.FilterEnvironment(environment,
GitCommandMode
.Captured);
72
[InlineData(nameof(
GitCommandMode
.Interactive))]
73
[InlineData(nameof(
GitCommandMode
.Unattended))]
84
GitCommandRunner.FilterEnvironment(environment, Enum.Parse<
GitCommandMode
>(mode));
95
[InlineData(nameof(
GitCommandMode
.Interactive), false)]
96
[InlineData(nameof(
GitCommandMode
.Interactive), true)]
97
[InlineData(nameof(
GitCommandMode
.Unattended), false)]
98
[InlineData(nameof(
GitCommandMode
.Unattended), true)]
113
GitCommandRunner.FilterEnvironment(environment, Enum.Parse<
GitCommandMode
>(mode));
146
runner.RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, TestContext.Current.CancellationToken));
164
[InlineData(nameof(
GitCommandMode
.Captured), nameof(GitFailure.AuthenticationFailed))]
165
[InlineData(nameof(
GitCommandMode
.Interactive), nameof(GitFailure.CommandFailed))]
166
[InlineData(nameof(
GitCommandMode
.Unattended), nameof(GitFailure.CommandFailed))]
169
var exception = GitCommandRunner.CreateCommandException("fatal: could not read Password", 128, Enum.Parse<
GitCommandMode
>(mode));
185
CreateRunner().RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, TestContext.Current.CancellationToken));
199
CreateRunner().RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, new CancellationToken(canceled: true)));
209
var output = await runner.RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
228
var run = runner.RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
258
var output = await runner.RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
282
var startInfo = runner.CreateStartInfo(Environment.CurrentDirectory, [command],
GitCommandMode
.Interactive);
294
GitCommandMode
.Interactive, TestContext.Current.CancellationToken);
324
var run = runner.RunProcessAsync(startInfo, captureCancellationOutput: true,
GitCommandMode
.Unattended, cancellation.Token);
353
GitCommandMode
.Captured, TestContext.Current.CancellationToken);
360
[InlineData(nameof(
GitCommandMode
.Captured), 0)]
361
[InlineData(nameof(
GitCommandMode
.Captured), 128)]
362
[InlineData(nameof(
GitCommandMode
.Interactive), 0)]
363
[InlineData(nameof(
GitCommandMode
.Interactive), 128)]
364
[InlineData(nameof(
GitCommandMode
.Unattended), 0)]
365
[InlineData(nameof(
GitCommandMode
.Unattended), 128)]
379
Enum.Parse<
GitCommandMode
>(mode), TestContext.Current.CancellationToken);
405
var startInfo = runner.CreateStartInfo(workspace.Path, ["fetch"],
GitCommandMode
.Captured);
418
var output = await runner.RunProcessAsync(startInfo, captureCancellationOutput: false,
GitCommandMode
.Captured, cancellation.Token);
Templating\TemplateEngineFactoryGitTests.cs (1)
88
Assert.All(commands.Commands, command => Assert.Equal(
GitCommandMode
.Captured, command.Mode));
TestServices\TestConfigSourceServices.cs (13)
96
public ConcurrentQueue<
GitCommandMode
> FetchModes { get; } = new();
97
public ConcurrentQueue<
GitCommandMode
> ResolutionModes { get; } = new();
104
GitCommandMode
mode, CancellationToken cancellationToken) => Task.CompletedTask;
106
public Task FetchAsync(GitRepositoryLocation destination, string repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken)
113
public Task<string> GetCommitAsync(GitRepositoryLocation repository, string reference,
GitCommandMode
mode, CancellationToken cancellationToken) =>
116
public async Task<GitTreeEntry?> GetFileAsync(GitRepositoryLocation repository, string commit, string path,
GitCommandMode
mode, CancellationToken cancellationToken)
127
if (state.Mode ==
GitCommandMode
.Unattended && !ReadConfigurationWhenUnattended)
142
public Task<long?> GetObjectSizeAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken) =>
145
public Task<string> ReadBlobAsync(GitRepositoryLocation repository, string objectId,
GitCommandMode
mode, CancellationToken cancellationToken) =>
148
public Task<string> ResolveReferenceAsync(string repository, string? reference, DirectoryInfo workingDirectory,
GitCommandMode
mode, CancellationToken cancellationToken)
154
public Task CheckoutAsync(GitRepositoryLocation repository,
GitCommandMode
mode, CancellationToken cancellationToken) =>
157
private sealed class RepositoryState(string repository, string reference,
GitCommandMode
mode)
161
public
GitCommandMode
Mode { get; } = mode;
TestServices\TestGitCommandRunner.cs (2)
54
public async Task<string> RunAsync(DirectoryInfo workingDirectory, string[] arguments,
GitCommandMode
mode, CancellationToken cancellationToken)
65
internal sealed record GitCommandInvocation(DirectoryInfo WorkingDirectory, string[] Arguments,
GitCommandMode
Mode);