Skip to content

Commit

Permalink
fix task input path resolve cuased by extra java env. (#1561)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang committed May 16, 2018
1 parent 7ddcba4 commit f5d48b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Agent.Worker/Build/TeeCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task GetAsync(string localPath)
public string ResolvePath(string serverPath)
{
ArgUtil.NotNullOrEmpty(serverPath, nameof(serverPath));
string localPath = RunPorcelainCommandAsync("resolvePath", $"-workspace:{WorkspaceName}", serverPath).GetAwaiter().GetResult();
string localPath = RunPorcelainCommandAsync(true, "resolvePath", $"-workspace:{WorkspaceName}", serverPath).GetAwaiter().GetResult();
localPath = localPath?.Trim();

// Paths outside of the root mapping return empty.
Expand Down Expand Up @@ -283,7 +283,7 @@ public async Task<ITfsVCWorkspace[]> WorkspacesAsync(bool matchWorkspaceNameOnAn
args.Add("-format:xml");

// Run the command.
TfsVCPorcelainCommandResult result = await TryRunPorcelainCommandAsync(FormatFlags.None, args.ToArray());
TfsVCPorcelainCommandResult result = await TryRunPorcelainCommandAsync(FormatFlags.None, false, args.ToArray());
ArgUtil.NotNull(result, nameof(result));
if (result.Exception != null)
{
Expand Down
27 changes: 22 additions & 5 deletions src/Agent.Worker/Build/TfsVCCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,20 @@ protected Task<string> RunPorcelainCommandAsync(params string[] args)
return RunPorcelainCommandAsync(FormatFlags.None, args);
}

protected async Task<string> RunPorcelainCommandAsync(FormatFlags formatFlags, params string[] args)
protected Task<string> RunPorcelainCommandAsync(bool ignoreStderr, params string[] args)
{
return RunPorcelainCommandAsync(FormatFlags.None, ignoreStderr, args);
}

protected Task<string> RunPorcelainCommandAsync(FormatFlags formatFlags, params string[] args)
{
return RunPorcelainCommandAsync(FormatFlags.None, false, args);
}

protected async Task<string> RunPorcelainCommandAsync(FormatFlags formatFlags, bool ignoreStderr, params string[] args)
{
// Run the command.
TfsVCPorcelainCommandResult result = await TryRunPorcelainCommandAsync(formatFlags, args);
TfsVCPorcelainCommandResult result = await TryRunPorcelainCommandAsync(formatFlags, ignoreStderr, args);
ArgUtil.NotNull(result, nameof(result));
if (result.Exception != null)
{
Expand All @@ -157,7 +167,7 @@ protected async Task<string> RunPorcelainCommandAsync(FormatFlags formatFlags, p
return string.Join(Environment.NewLine, result.Output ?? new List<string>());
}

protected async Task<TfsVCPorcelainCommandResult> TryRunPorcelainCommandAsync(FormatFlags formatFlags, params string[] args)
protected async Task<TfsVCPorcelainCommandResult> TryRunPorcelainCommandAsync(FormatFlags formatFlags, bool ignoreStderr, params string[] args)
{
// Validation.
ArgUtil.NotNull(args, nameof(args));
Expand All @@ -180,8 +190,15 @@ protected async Task<TfsVCPorcelainCommandResult> TryRunPorcelainCommandAsync(Fo
{
lock (outputLock)
{
ExecutionContext.Debug(e.Data);
result.Output.Add(e.Data);
if (ignoreStderr)
{
ExecutionContext.Output(e.Data);
}
else
{
ExecutionContext.Debug(e.Data);
result.Output.Add(e.Data);
}
}
};
string arguments = FormatArguments(formatFlags, args);
Expand Down

0 comments on commit f5d48b0

Please sign in to comment.