Skip to content

Commit d5650c7

Browse files
committed
Anonymize diagnostics information
1 parent c405e63 commit d5650c7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/nugraph/GraphCommand.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ private static async Task<int> DiagnoseAsync(TextWriter stdOut, DirectoryInfo? s
8989
await stdOut.WriteLineAsync();
9090

9191
await stdOut.WriteLineAsync("assemblies:");
92+
var userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
93+
var userProfileReplacement = OperatingSystem.IsWindows() ? "%UserProfile%" : "~";
9294
foreach (var assembly in typeof(Program).Assembly.LoadReferencedAssemblies().OrderBy(a => a.GetName().Name))
9395
{
94-
await stdOut.WriteLineAsync($" {assembly}: {assembly.Location}");
96+
await stdOut.WriteLineAsync($" {assembly}: {assembly.Location.Replace(userProfile, userProfileReplacement)}");
9597
}
9698
await stdOut.WriteLineAsync();
9799

tests/nugraph.Tests/NugraphTests.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
using System;
12
using System.IO;
23
using System.Threading.Tasks;
4+
using AwesomeAssertions;
5+
using AwesomeAssertions.Execution;
36
using NuGet.Common;
47

58
namespace nugraph.Tests;
@@ -19,7 +22,11 @@ public async Task Diagnose()
1922

2023
await File.WriteAllTextAsync($"{nugraph.GetType().Name}.diagnostics.txt", result.StdOut);
2124

22-
result.Should().Match(stdOutPattern: "nugraph:*");
25+
using (new AssertionScope())
26+
{
27+
result.Should().Match(stdOutPattern: "nugraph:*");
28+
result.StdOut.Should().NotContain(Path.DirectorySeparatorChar + Environment.UserName + Path.DirectorySeparatorChar);
29+
}
2330
}
2431

2532
[Test]

0 commit comments

Comments
 (0)