Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance dotnet-roslyn prfinder to support AzDO repos. #1191

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions RoslynTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "roslyn.optprof.runsettings.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitHubCreateMergePRs", "src\GitHubCreateMergePRs\GitHubCreateMergePRs.csproj", "{491D6953-5267-463F-9796-E9906B2FE516}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PRFinder", "src\RoslynInsertionTool\PRFinder\PRFinder.csproj", "{15BE78E3-355F-4B15-ABB4-FA750B2D846B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CreateTagsForVSRelease", "src\CreateTagsForVSRelease\CreateTagsForVSRelease.csproj", "{08AAEF36-C81B-4BAE-8172-EA0D3139B0BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NugetDependencyFinder", "src\NugetDependencyFinder\NugetDependencyFinder.csproj", "{7A6963D6-1F40-4CC6-9941-7F912252F877}"
Expand Down Expand Up @@ -336,18 +334,6 @@ Global
{491D6953-5267-463F-9796-E9906B2FE516}.Release|x64.Build.0 = Release|Any CPU
{491D6953-5267-463F-9796-E9906B2FE516}.Release|x86.ActiveCfg = Release|Any CPU
{491D6953-5267-463F-9796-E9906B2FE516}.Release|x86.Build.0 = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|x64.ActiveCfg = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|x64.Build.0 = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|x86.ActiveCfg = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Debug|x86.Build.0 = Debug|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|Any CPU.Build.0 = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|x64.ActiveCfg = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|x64.Build.0 = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|x86.ActiveCfg = Release|Any CPU
{15BE78E3-355F-4B15-ABB4-FA750B2D846B}.Release|x86.Build.0 = Release|Any CPU
{08AAEF36-C81B-4BAE-8172-EA0D3139B0BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08AAEF36-C81B-4BAE-8172-EA0D3139B0BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08AAEF36-C81B-4BAE-8172-EA0D3139B0BE}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -409,7 +395,6 @@ Global
{01128CF6-4519-436E-B21F-F691DC6A9832} = {821F3F43-E221-4507-95BD-64843868AC11}
{CCE71F35-DCD5-4008-9DC5-677431E87494} = {821F3F43-E221-4507-95BD-64843868AC11}
{44B80D37-F395-40CF-8BB6-9AAEB5606672} = {821F3F43-E221-4507-95BD-64843868AC11}
{15BE78E3-355F-4B15-ABB4-FA750B2D846B} = {54B3835F-17DD-4749-B40D-1533BD81D36C}
{7A6963D6-1F40-4CC6-9941-7F912252F877} = {732A897A-76AE-41E3-A7E4-55F16C1D56EB}
{1D14C80C-B4C3-42C1-BA4C-8A81427CA44D} = {C68033E0-FB8F-4327-BFB5-B340A5A7778F}
EndGlobalSection
Expand Down
15 changes: 0 additions & 15 deletions src/RoslynInsertionTool/PRFinder/PRFinder.csproj

This file was deleted.

98 changes: 0 additions & 98 deletions src/RoslynInsertionTool/PRFinder/Program.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/dotnet-roslyn/Commands/CreateReleaseTagsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class CreateReleaseTagsCommand

public static Symbol GetCommand()
{
var command = new Command("create-release-tags", "Generates tags for VS releases in the Roslyn repo.")
var command = new Command("create-release-tags", "Generates git tags for VS releases in the Roslyn repo.")
{
VerbosityOption
};
Expand Down
4 changes: 2 additions & 2 deletions src/dotnet-roslyn/Commands/PRFinderCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public static Symbol GetCommand()

private class PrFinderCommandDefaultHandler : ICommandHandler
{
public async Task<int> InvokeAsync(InvocationContext context)
public Task<int> InvokeAsync(InvocationContext context)
{
var logger = context.SetupLogging();

var previousCommit = context.ParseResult.GetValueForOption(PreviousCommitShaOption)!;
var currentCommit = context.ParseResult.GetValueForOption(CurrentCommitSHAOption)!;

return await PRFinder.PRFinder.FindPRsAsync(previousCommit, currentCommit, logger);
return Task.FromResult(PRFinder.PRFinder.FindPRs(previousCommit, currentCommit, logger));
}
}
}
1 change: 1 addition & 0 deletions src/dotnet-roslyn/Commands/RootRoslynCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public static RootCommand GetRootCommand()
VSBranchInfoCommand.GetCommand(),
};
command.Name = "roslyn";
command.Description = "The command line tool for performing Roslyn infrastructure tasks.";
return command;
}
}
52 changes: 0 additions & 52 deletions src/dotnet-roslyn/CreateReleaseTags/AzDOConnection.cs

This file was deleted.

3 changes: 2 additions & 1 deletion src/dotnet-roslyn/CreateReleaseTags/CreateReleaseTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Azure.Security.KeyVault.Secrets;
using LibGit2Sharp;
using Microsoft.Extensions.Logging;
using Microsoft.Roslyn.Utilities;
using Microsoft.TeamFoundation.SourceControl.WebApi;
using Newtonsoft.Json.Linq;
using System.Collections.Immutable;
Expand Down Expand Up @@ -148,7 +149,7 @@ public static async Task<int> CreateReleaseTagsAsync(ILogger logger)
{
return default;
}

var parts = languageServicesUrlAndManifestName.Split(';');
if (parts.Length != 2)
{
Expand Down
70 changes: 70 additions & 0 deletions src/dotnet-roslyn/PRFinder/Hosts/Azure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Licensed to the.NET Foundation under one or more agreements.
// The.NET Foundation licenses this file to you under the MIT license.
// See the License.txt file in the project root for more information.

using System.Text.RegularExpressions;
using LibGit2Sharp;

namespace Microsoft.Roslyn.Tool.PRFinder.Hosts;

public class Azure : IRepositoryHost
{
private static readonly Regex IsAzDOReleaseFlowCommit = new Regex(@"^Merged PR \d+: Merging .* to ");
private static readonly Regex IsAzDOMergePRCommit = new Regex(@"^Merged PR (\d+):");

public string GetCommitUrl(string repoUrl, string commitSha)
=> $"{repoUrl}/commit/{commitSha}";

public string GetDiffUrl(string repoUrl, string previousSha, string currentSha)
// AzDO does not have a UI for comparing two commits. Instead generate the REST API call to retrieve commits between two SHAs.
=> $"{repoUrl.Replace("_git", "_apis/git/repositories")}/commits?searchCriteria.itemVersion.version={previousSha}&searchCriteria.itemVersion.versionType=commit&searchCriteria.compareVersion.version={currentSha}&searchCriteria.compareVersion.versionType=commit";

public string GetPullRequestUrl(string repoUrl, string prNumber)
=> $"{repoUrl}/pullrequest/{prNumber}";

public bool ShouldSkip(Commit commit, ref bool mergePRFound)
{
// Exclude arcade dependency updates
if (commit.Author.Name == "DotNet Bot")
{
mergePRFound = true;
return true;
}

// Exclude OneLoc localization PRs
if (commit.Author.Name == "Project Collection Build Service (devdiv)")
{
mergePRFound = true;
return true;
}

// Exclude merge commits from auto code-flow PRs (e.g. main to Dev17)
if (IsAzDOReleaseFlowCommit.Match(commit.MessageShort).Success)
{
mergePRFound = true;
return true;
}

return false;
}

public bool TryParseMergeInfo(Commit commit, out string prNumber, out string comment)
{
var match = IsAzDOMergePRCommit.Match(commit.Message);
if (match.Success)
{
// Merge PR Messages are in the form "Merged PR 320820: Resolving encoding issue on test summary pane, using UTF8 now\n\nAdded a StreamWriterWrapper to resolve encoding issue"
comment = commit.MessageShort;
prNumber = match.Groups[1].Value;
return true;
}
else
{
// Todo: Determine if there is a format for AzDO squash merges that preserves the PR #
}

comment = string.Empty;
prNumber = string.Empty;
return false;
}
}
Loading