Skip to content

Commit

Permalink
Revert "remove issue generation on warning/error commands (#137)" (#147)
Browse files Browse the repository at this point in the history
* Revert "remove issue generation on warning/error commands (#137)"

This reverts commit 53da198.

* Updated Release notes
  • Loading branch information
thboop authored Oct 28, 2019
1 parent 76bb496 commit 6a063ae
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion releaseNote.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions src/Runner.Worker/ActionCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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
Expand Down

0 comments on commit 6a063ae

Please sign in to comment.