From 7d316c0a75bb531eac84834484c8a5c4436f07c7 Mon Sep 17 00:00:00 2001 From: TingluoHuang Date: Wed, 20 Apr 2022 00:56:38 -0400 Subject: [PATCH] Add notice annotation for the git unsafe directory error. --- src/Runner.Worker/Handlers/OutputManager.cs | 6 ++++++ src/Test/L0/Worker/OutputManagerL0.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Runner.Worker/Handlers/OutputManager.cs b/src/Runner.Worker/Handlers/OutputManager.cs index a67e35e21..c99370121 100644 --- a/src/Runner.Worker/Handlers/OutputManager.cs +++ b/src/Runner.Worker/Handlers/OutputManager.cs @@ -154,6 +154,12 @@ namespace GitHub.Runner.Worker.Handlers if (line.Contains("fatal: unsafe repository", StringComparison.OrdinalIgnoreCase)) { _executionContext.StepTelemetry.ErrorMessages.Add(line); + var gitUnsafeDirNotice = new DTWebApi.Issue + { + Message = $"You may experience error caused by a recently git safe directory enforcement. For more information see: https://github.blog/changelog/xxx", + Type = DTWebApi.IssueType.Notice, + }; + _executionContext.AddIssue(gitUnsafeDirNotice); } // Regular output diff --git a/src/Test/L0/Worker/OutputManagerL0.cs b/src/Test/L0/Worker/OutputManagerL0.cs index 85045802a..dd5de3136 100644 --- a/src/Test/L0/Worker/OutputManagerL0.cs +++ b/src/Test/L0/Worker/OutputManagerL0.cs @@ -947,6 +947,7 @@ namespace GitHub.Runner.Common.Tests.Worker { Process("fatal: unsafe repository ('/github/workspace' is owned by someone else)"); Assert.Contains("fatal: unsafe repository ('/github/workspace' is owned by someone else)", _executionContext.Object.StepTelemetry.ErrorMessages); + Assert.Contains(_issues, x => x.Item1.Type == DTWebApi.IssueType.Notice && x.Item1.Message.Contains("You may experience error caused by a recently git safe directory enforcement")); } }