From 8adfab91ad5c96074de1c8edd9721e3dcc43bde2 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Mon, 10 Apr 2023 22:10:22 +0000 Subject: [PATCH] Revert sourcelink patch, will need to flow in latest version --- .../sourcelink/0002-Fix-FileWrites-995.patch | 276 ------------------ 1 file changed, 276 deletions(-) delete mode 100644 src/SourceBuild/patches/sourcelink/0002-Fix-FileWrites-995.patch diff --git a/src/SourceBuild/patches/sourcelink/0002-Fix-FileWrites-995.patch b/src/SourceBuild/patches/sourcelink/0002-Fix-FileWrites-995.patch deleted file mode 100644 index 509e25465..000000000 --- a/src/SourceBuild/patches/sourcelink/0002-Fix-FileWrites-995.patch +++ /dev/null @@ -1,276 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Matou=C5=A1ek?= - -Date: Mon, 10 Apr 2023 14:25:53 -0700 -Subject: [PATCH] Fix FileWrites (#995) - -Backport: https://github.com/dotnet/sourcelink/issues/993 ---- - .../GenerateSourceLinkFileTests.cs | 4 -- - .../GenerateSourceLinkFile.cs | 16 +---- - .../build/Microsoft.SourceLink.Common.targets | 11 +++- - .../CloudHostedProvidersTests.cs | 61 ++++++++++++++----- - 4 files changed, 56 insertions(+), 36 deletions(-) - -diff --git a/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs b/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs -index 50ecb7c..9234421 100644 ---- a/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs -+++ b/src/SourceLink.Common.UnitTests/GenerateSourceLinkFileTests.cs -@@ -40,7 +40,6 @@ public void Empty(bool noWarning) - AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedOutput, engine.Log); - - Assert.Null(task.SourceLink); -- Assert.Null(task.FileWrite); - } - - [Theory] -@@ -73,7 +72,6 @@ public void NoRepositoryUrl(bool noWarning) - AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedOutput, engine.Log); - - Assert.Null(task.SourceLink); -- Assert.Null(task.FileWrite); - } - - [Fact] -@@ -100,7 +98,6 @@ public void Empty_DeleteExistingFile() - string.Format(Resources.SourceLinkEmptyDeletingExistingFile, sourceLinkFile.Path), engine.Log); - - Assert.Null(task.SourceLink); -- Assert.Equal(sourceLinkFile.Path, task.FileWrite); - } - - [Fact] -@@ -235,7 +232,6 @@ public void DoesNotRewriteContentIfFileContentIsSame() - - Assert.Equal(@"{""documents"":{""/_\""_/*"":""https://raw.githubusercontent.com/repo/*""}}", File.ReadAllText(tempFile.Path, Encoding.UTF8)); - Assert.Equal(tempFile.Path, task.SourceLink); -- Assert.Equal(tempFile.Path, task.FileWrite); - - result = task.Execute(); - -diff --git a/src/SourceLink.Common/GenerateSourceLinkFile.cs b/src/SourceLink.Common/GenerateSourceLinkFile.cs -index 8a07616..859cf0d 100644 ---- a/src/SourceLink.Common/GenerateSourceLinkFile.cs -+++ b/src/SourceLink.Common/GenerateSourceLinkFile.cs -@@ -21,12 +21,6 @@ public sealed class GenerateSourceLinkFile : Task - [Required, NotNull] - public string? OutputFile { get; set; } - -- /// -- /// Set to if the output file was written to, null otherwise. -- /// -- [Output] -- public string? FileWrite { get; set; } -- - /// - /// Set to if the output Source Link file should be passed to the compiler. - /// -@@ -60,14 +54,14 @@ static string jsonEscape(string str) - - if (!localPath.EndsWithSeparator()) - { -- Log.LogError(Resources.MustEndWithDirectorySeparator, (isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name), localPath); -+ Log.LogError(Resources.MustEndWithDirectorySeparator, isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name, localPath); - success = false; - continue; - } - - if (localPath.Contains('*')) - { -- Log.LogError(Resources.MustNotContainWildcard, (isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name), localPath); -+ Log.LogError(Resources.MustNotContainWildcard, isMapped ? Names.SourceRoot.MappedPathFullName : Names.SourceRoot.Name, localPath); - success = false; - continue; - } -@@ -127,7 +121,6 @@ private void WriteSourceLinkFile(string? content) - Log.LogMessage(Resources.SourceLinkEmptyDeletingExistingFile, OutputFile); - - File.Delete(OutputFile); -- FileWrite = OutputFile; - return; - } - -@@ -151,14 +144,11 @@ private void WriteSourceLinkFile(string? content) - - Log.LogMessage(Resources.SourceLinkFileUpdated, OutputFile); - File.WriteAllText(OutputFile, content); -- FileWrite = SourceLink = OutputFile; -+ SourceLink = OutputFile; - } - catch (Exception e) - { - Log.LogError(Resources.ErrorWritingToSourceLinkFile, OutputFile, e.Message); -- -- // Part of the file might have been written. -- FileWrite = OutputFile; - } - } - } -diff --git a/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets b/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets -index ea05b19..0f9a861 100644 ---- a/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets -+++ b/src/SourceLink.Common/build/Microsoft.SourceLink.Common.targets -@@ -58,11 +58,16 @@ - - - -- -- -- - - -+ -+ -+ -+ -+ - - - -diff --git a/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs b/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs -index 8a91a9a..58129d0 100644 ---- a/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs -+++ b/src/SourceLink.Git.IntegrationTests/CloudHostedProvidersTests.cs -@@ -131,6 +131,11 @@ public void NoCommit_NoRemote_NoWarnings() - - - -+ -+ -+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/> -+ -+ - """, - customTargets: "", - targets: new[] -@@ -141,11 +146,13 @@ public void NoCommit_NoRemote_NoWarnings() - { - "@(SourceRoot)", - "$(SourceLink)", -+ "@(_SourceLinkFileWrites)", - }, - expectedResults: new[] - { - NuGetPackageFolders, - "", -+ "", - }); - } - -@@ -160,6 +167,11 @@ public void Commit_NoRemote_NoWarnings() - - - -+ -+ -+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/> -+ -+ - """, - customTargets: "", - targets: new[] -@@ -170,12 +182,14 @@ public void Commit_NoRemote_NoWarnings() - { - "@(SourceRoot)", - "$(SourceLink)", -+ "@(_SourceLinkFileWrites)", - }, - expectedResults: new[] - { - NuGetPackageFolders, - ProjectSourceRoot, - "", -+ "", - }); - } - -@@ -190,6 +204,11 @@ public void NoCommit_Remote_NoWarnings() - - - -+ -+ -+ <_SourceLinkFileWrites Include="@(FileWrites)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))"/> -+ -+ - """, - customTargets: "", - targets: new[] -@@ -200,11 +219,13 @@ public void NoCommit_Remote_NoWarnings() - { - "@(SourceRoot)", - "$(SourceLink)", -+ "@(_SourceLinkFileWrites)", - }, - expectedResults: new[] - { - NuGetPackageFolders, - "", -+ "", - }); - } - -@@ -230,21 +251,27 @@ public void CustomTranslation() - DependsOnTargets=""$(SourceControlManagerUrlTranslationTargets)"" - BeforeTargets=""SourceControlManagerPublishTranslatedUrls""> - -- -- <_Pattern>https://([^.]+)[.]visualstudio.com/([^/]+)/_git/([^/]+) -- <_Replacement>https://github.com/$2/$3 -- -- -- -- $([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_Pattern), $(_Replacement))) -- -- -- -- -- $([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_Pattern), $(_Replacement))) -- -- -- -+ -+ <_Pattern>https://([^.]+)[.]visualstudio.com/([^/]+)/_git/([^/]+) -+ <_Replacement>https://github.com/$2/$3 -+ -+ -+ -+ $([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_Pattern), $(_Replacement))) -+ -+ -+ -+ -+ $([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_Pattern), $(_Replacement))) -+ -+ -+ -+ -+ -+ -+ <_SourceLinkFileWrites Include=""@(FileWrites)"" Condition=""$([MSBuild]::ValueOrDefault('%(Identity)', '').EndsWith('sourcelink.json'))""/> -+ -+ - ", - targets: new[] - { -@@ -256,7 +283,8 @@ public void CustomTranslation() - "@(SourceRoot->'%(SourceLinkUrl)')", - "$(SourceLink)", - "$(PrivateRepositoryUrl)", -- "$(RepositoryUrl)" -+ "$(RepositoryUrl)", -+ "@(_SourceLinkFileWrites)", - }, - expectedResults: new[] - { -@@ -266,6 +294,7 @@ public void CustomTranslation() - s_relativeSourceLinkJsonPath, - $"https://github.com/test-org/{repoName}", - $"https://github.com/test-org/{repoName}", -+ s_relativeSourceLinkJsonPath - }); - - AssertEx.AreEqual(