From 6a063ae7be2ff8abc88a88c7c049455c32bb48ac Mon Sep 17 00:00:00 2001 From: Thomas Boop <52323235+thboop@users.noreply.github.com> Date: Mon, 28 Oct 2019 11:12:31 -0400 Subject: [PATCH] Revert "remove issue generation on warning/error commands (#137)" (#147) * Revert "remove issue generation on warning/error commands (#137)" This reverts commit 53da19886768e053ff15beec406709571e091feb. * Updated Release notes --- releaseNote.md | 2 +- src/Runner.Worker/ActionCommandManager.cs | 49 +++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/releaseNote.md b/releaseNote.md index 93eeb6d081e..6c57e00259d 100644 --- a/releaseNote.md +++ b/releaseNote.md @@ -2,7 +2,7 @@ - N/A ## Bugs - - N/A + - Reverted removal of additional fields error and warning fields (#147) ## Misc - Updated to .NET Core 3.0 (#127) diff --git a/src/Runner.Worker/ActionCommandManager.cs b/src/Runner.Worker/ActionCommandManager.cs index cf3b354795b..a2819fdccb7 100644 --- a/src/Runner.Worker/ActionCommandManager.cs +++ b/src/Runner.Worker/ActionCommandManager.cs @@ -441,6 +441,9 @@ public abstract class IssueCommandExtension : RunnerService, IActionCommandExten public void ProcessCommand(IExecutionContext context, string inputLine, ActionCommand command, out bool omitEcho) { omitEcho = true; + command.Properties.TryGetValue(IssueCommandProperties.File, out string file); + command.Properties.TryGetValue(IssueCommandProperties.Line, out string line); + command.Properties.TryGetValue(IssueCommandProperties.Column, out string column); Issue issue = new Issue() { @@ -449,8 +452,54 @@ public void ProcessCommand(IExecutionContext context, string inputLine, ActionCo Message = command.Data }; + if (!string.IsNullOrEmpty(file)) + { + issue.Category = "Code"; + + if (context.Container != null) + { + // Translate file path back from container path + file = context.Container.TranslateToHostPath(file); + command.Properties[IssueCommandProperties.File] = file; + } + + // Get the values that represent the server path given a local path + string repoName = context.GetGitHubContext("repository"); + var repoPath = context.GetGitHubContext("workspace"); + + string relativeSourcePath = IOUtil.MakeRelative(file, repoPath); + if (!string.Equals(relativeSourcePath, file, IOUtil.FilePathStringComparison)) + { + // add repo info + if (!string.IsNullOrEmpty(repoName)) + { + command.Properties["repo"] = repoName; + } + + if (!string.IsNullOrEmpty(relativeSourcePath)) + { + // replace sourcePath with the new relative path + // prefer `/` on all platforms + command.Properties[IssueCommandProperties.File] = relativeSourcePath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); + } + } + } + + foreach (var property in command.Properties) + { + issue.Data[property.Key] = property.Value; + } + context.AddIssue(issue); } + + private static class IssueCommandProperties + { + public const String File = "file"; + public const String Line = "line"; + public const String Column = "col"; + } + } public sealed class GroupCommandExtension : GroupingCommandExtension