diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/MockGitHubEventClient.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/MockGitHubEventClient.cs index d606b68bf19..ecd22498043 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/MockGitHubEventClient.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/MockGitHubEventClient.cs @@ -50,7 +50,7 @@ public MockGitHubEventClient(string productHeaderName, string? rulesConfigLocati /// /// /// - /// + /// integer,the number of pending updates that would be processed public override Task ProcessPendingUpdates(long repositoryId, int issueOrPullRequestNumber = 0) { int numUpdates = 0; @@ -81,9 +81,9 @@ public override Task ProcessPendingUpdates(long repositoryId, int issueOrPu /// /// IsUserCollaborator override. Returns IsCollaboratorReturn value /// - /// - /// - /// + /// The Id of the repository + /// The User.Login for the event object from the action payload + /// bool, returns the IsCollaboratorReturn set for testing public override Task IsUserCollaborator(long repositoryId, string user) { return Task.FromResult(IsCollaboratorReturn); @@ -92,22 +92,22 @@ public override Task IsUserCollaborator(long repositoryId, string user) /// /// IsUserMemberOfOrg override. Returns IsUserMemberOfOrgReturn value /// - /// - /// - /// + /// The organization name. + /// The User.Login for the event object from the action payload + /// bool, returns IsUserMemberOfOrgReturn set for testing public override Task IsUserMemberOfOrg(string orgName, string user) { - return Task.FromResult(IsCollaboratorReturn); + return Task.FromResult(IsUserMemberOfOrgReturn); } /// /// DoesUserHavePermissions override. Returns UserHasPermissionsReturn value /// - /// - /// - /// - /// + /// The Id of the repository + /// The User.Login for the event object from the action payload + /// The list of permissions to check for. + /// bool, returns UserHasPermissionsReturn for testing public override Task DoesUserHavePermissions(long repositoryId, string user, List permissionList) { return Task.FromResult(UserHasPermissionsReturn); @@ -224,7 +224,7 @@ public void CreateFakeReviewsForPullRequest(int numApproved, int numNotApproved) /// and private setters. This means everything needs to be passed into the constructor. /// /// This will become string that'll be the User.Login - /// + /// Octokit.User internal User CreateFakeUser(string fakeLogin) { DateTimeOffset dateTimeOffset= DateTimeOffset.Now; @@ -299,7 +299,7 @@ internal User CreateFakeUser(string fakeLogin) /// fake Octokit.User, created using CreateFakeUser /// Octokit.PullRequestReviewState, the state of the review /// Fake prReviewId, it'll match the number of the fakeUser{number} - /// + /// Octkit.PullRequestReview internal PullRequestReview CreateFakeReview(User fakeUser, PullRequestReviewState prReviewState, long prReviewId) { PullRequestReview prReview = new PullRequestReview( @@ -381,7 +381,7 @@ public void CreateFakePullRequestFiles(List prFiles) /// all rules defaulting to RuleState.On, otherwise load the rulesConfiguration from the location. /// /// Rules configuration location - /// + /// RulesConfiguration public override RulesConfiguration LoadRulesConfiguration(string? rulesConfigLocation = null) { RulesConfiguration? rulesConfiguration = null; diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/README.md b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/README.md index dc5339af96d..d44f9fce815 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/README.md +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/README.md @@ -81,7 +81,7 @@ The GitHubEventClient is a singleton used by workflow processing and any/all ext ## Live Testing -[azure-sdk/github-event-processor-test](https://github.com/azure-sdk/github-event-processor-test) is a repository which was specifically setup for testing purposes and can be used to generate static payloads. The .github\workflow contains the [config and workflow yml files](../YmlAndConfigFiles/) which, aside from different confi files, the final version of the workflow files. Every Action rule can be setup through creation and modification of issues and pull requests within the repository and every action has been tested this way. Scheduled events are a little different to test live because constraints dealing with time. Every scheduled event has "last modified X days ago" as part of its criteria ranging from 7 to 90 days which isn't something that can be created on the fly. +[azure-sdk/github-event-processor-test](https://github.com/azure-sdk/github-event-processor-test) is a repository which was specifically setup for testing purposes and can be used to generate static payloads. The .github\workflow contains the [config and workflow yml files](../YmlAndConfigFiles/) which, aside from different config files, the final version of the workflow files. Every Action rule can be setup through creation and modification of issues and pull requests within the repository and every action has been tested this way. Scheduled events are a little different to test live because constraints dealing with time. Every scheduled event has "last modified X days ago" as part of its criteria ranging from 7 to 90 days which isn't something that can be created on the fly. ### Other requirements of the test repository diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/Static/IssueCommentProcessingTests.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/Static/IssueCommentProcessingTests.cs index 5a5dfdf3c0a..c2d78616414 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/Static/IssueCommentProcessingTests.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor.Tests/Static/IssueCommentProcessingTests.cs @@ -23,7 +23,6 @@ public class IssueCommentProcessingTests : ProcessingTestBase /// String, RulesConstants for the rule being tested /// JSon payload file for the event being tested /// Whether or not the rule is on/off - /// [Category("static")] [TestCase(RulesConstants.AuthorFeedback, "Tests.JsonEventPayloads/AuthorFeedBack_issue_comment_created.json", RuleState.On)] [TestCase(RulesConstants.AuthorFeedback, "Tests.JsonEventPayloads/AuthorFeedBack_issue_comment_created.json", RuleState.Off)] @@ -68,7 +67,6 @@ public async Task TestAuthorFeedback(string rule, string payloadFile, RuleState /// String, RulesConstants for the rule being tested /// JSon payload file for the event being tested /// Whether or not the rule is on/off - /// [Category("static")] [TestCase(RulesConstants.ResetIssueActivity, "Tests.JsonEventPayloads/ResetIssueActivity_issue_comment_created.json", RuleState.On)] [TestCase(RulesConstants.ResetIssueActivity, "Tests.JsonEventPayloads/ResetIssueActivity_issue_comment_created.json", RuleState.Off)] @@ -109,7 +107,6 @@ public async Task TestResetIssueActivity(string rule, string payloadFile, RuleSt /// String, RulesConstants for the rule being tested /// JSon payload file for the event being tested /// Whether or not the rule is on/off - /// [Category("static")] [TestCase(RulesConstants.ReopenIssue, "Tests.JsonEventPayloads/ReopenIssue_issue_comment_created.json", RuleState.On)] [TestCase(RulesConstants.ReopenIssue, "Tests.JsonEventPayloads/ReopenIssue_issue_comment_created.json", RuleState.Off)] @@ -157,7 +154,6 @@ public async Task TestReopenIssue(string rule, string payloadFile, RuleState rul /// String, RulesConstants for the rule being tested /// JSon payload file for the event being tested /// Whether or not the rule is on/off - /// [Category("static")] [TestCase(RulesConstants.DeclineToReopenIssue, "Tests.JsonEventPayloads/DeclineToReopenIssue_issue_comment_created.json", RuleState.On)] [TestCase(RulesConstants.DeclineToReopenIssue, "Tests.JsonEventPayloads/DeclineToReopenIssue_issue_comment_created.json", RuleState.Off)] @@ -204,7 +200,6 @@ public async Task TestDeclineToReopenIssue(string rule, string payloadFile, Rule /// JSon payload file for the event being tested /// Whether or not the rule is on/off /// Whether or not the user has Admin or Write permission. - /// [Category("static")] [TestCase(RulesConstants.IssueAddressedCommands, "Tests.JsonEventPayloads/IssueAddressedCommands_issue_comment_created_same_user.json", RuleState.On, true)] [TestCase(RulesConstants.IssueAddressedCommands, "Tests.JsonEventPayloads/IssueAddressedCommands_issue_comment_created_same_user.json", RuleState.On, false)] @@ -257,7 +252,6 @@ public async Task TestIssueAddressedCommands_SameUser(string rule, string payloa /// String, RulesConstants for the rule being tested /// JSon payload file for the event being tested /// Whether or not the user has Admin or Write permission. - /// [Category("static")] [TestCase(RulesConstants.IssueAddressedCommands, "Tests.JsonEventPayloads/IssueAddressedCommands_issue_comment_created_different_user.json", true)] [TestCase(RulesConstants.IssueAddressedCommands, "Tests.JsonEventPayloads/IssueAddressedCommands_issue_comment_created_different_user.json", false)] diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/ActionConstants.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/ActionConstants.cs index 93cbc753737..204ea67f534 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/ActionConstants.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/ActionConstants.cs @@ -12,26 +12,26 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Constants /// public class ActionConstants { - public static readonly string Assigned = "assigned"; - public static readonly string Created = "created"; - public static readonly string Closed = "closed"; - public static readonly string Deleted = "deleted"; - public static readonly string Demilestoned = "demilestoned"; - public static readonly string Dismissed = "dismissed"; - public static readonly string Edited = "edited"; - public static readonly string Labeled = "labeled"; - public static readonly string Locked = "locked"; - public static readonly string Milestoned = "milestoned"; - public static readonly string Opened = "opened"; - public static readonly string Pinned = "pinned"; - public static readonly string Reopened = "reopened"; - public static readonly string ReviewRequested = "review_requested"; - public static readonly string Submitted = "submitted"; - public static readonly string Synchronize = "synchronize"; - public static readonly string Transferred = "transferred"; - public static readonly string Unassigned = "unassigned"; - public static readonly string Unlabeled = "unlabeled"; - public static readonly string Unlocked = "unlocked"; - public static readonly string Unpinned = "unpinned"; + public const string Assigned = "assigned"; + public const string Created = "created"; + public const string Closed = "closed"; + public const string Deleted = "deleted"; + public const string Demilestoned = "demilestoned"; + public const string Dismissed = "dismissed"; + public const string Edited = "edited"; + public const string Labeled = "labeled"; + public const string Locked = "locked"; + public const string Milestoned = "milestoned"; + public const string Opened = "opened"; + public const string Pinned = "pinned"; + public const string Reopened = "reopened"; + public const string ReviewRequested = "review_requested"; + public const string Submitted = "submitted"; + public const string Synchronize = "synchronize"; + public const string Transferred = "transferred"; + public const string Unassigned = "unassigned"; + public const string Unlabeled = "unlabeled"; + public const string Unlocked = "unlocked"; + public const string Unpinned = "unpinned"; } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/CommentConstants.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/CommentConstants.cs index fcce38314e9..abd9c91c5b3 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/CommentConstants.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/CommentConstants.cs @@ -12,17 +12,17 @@ public class CommentConstants { // /azp does things like prepares new pipelines or kicks off pipelines and should // also be ignored for comment processing. - public static readonly string Azp = "/azp"; + public const string Azp = "/azp"; // Check Enforcer commands are all /check-enforcer // "What is Check Enforcer" is effectively dead - public static readonly string CheckEnforcer = "/check-enforcer"; + public const string CheckEnforcer = "/check-enforcer"; // This is used to reopen an issue in a comment and causes actions to happen - public static readonly string Reopen = "/reopen"; + public const string Reopen = "/reopen"; // This is part of the message that's added to a PR that's being closed as part of the cron job that // closes stale pull requests. There's a rule that looks for this string as part of a pull request comment to // prevent an action. - public static readonly string ScheduledCloseFragment = "Since there hasn't been recent engagement, this is being closed out."; + public const string ScheduledCloseFragment = "Since there hasn't been recent engagement, this is being closed out."; // used to unresolve an issue in a comment and causes actions to happen - public static readonly string Unresolve = "/unresolve"; + public const string Unresolve = "/unresolve"; } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/EventConstants.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/EventConstants.cs index cd9e2a82330..6c19177c4cf 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/EventConstants.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/EventConstants.cs @@ -11,10 +11,10 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Constants /// public class EventConstants { - public const string issues = "issues"; - public const string issue_comment = "issue_comment"; - public const string pull_request_review = "pull_request_review"; - public const string pull_request_target = "pull_request_target"; - public const string schedule = "schedule"; + public const string Issues = "issues"; + public const string IssueComment = "issue_comment"; + public const string PullRequestReview = "pull_request_review"; + public const string PullRequestTarget = "pull_request_target"; + public const string Schedule = "schedule"; } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/LabelConstants.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/LabelConstants.cs index ce40bb3c5e8..3c96389b383 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/LabelConstants.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/LabelConstants.cs @@ -12,16 +12,16 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Constants /// public class LabelConstants { - public static readonly string CommunityContribution = "Community Contribution"; - public static readonly string CustomerReported = "customer-reported"; - public static readonly string CXPAttention = "CXP Attention"; - public static readonly string IssueAddressed = "issue-addressed"; - public static readonly string NeedsAuthorFeedback = "needs-author-feedback"; - public static readonly string NeedsTeamAttention = "needs-team-attention"; - public static readonly string NeedsTeamTriage = "needs-team-triage"; - public static readonly string NeedsTriage = "needs-triage"; - public static readonly string NoRecentActivity = "no-recent-activity"; - public static readonly string Question = "question"; - public static readonly string ServiceAttention = "Service Attention"; + public const string CommunityContribution = "Community Contribution"; + public const string CustomerReported = "customer-reported"; + public const string CXPAttention = "CXP Attention"; + public const string IssueAddressed = "issue-addressed"; + public const string NeedsAuthorFeedback = "needs-author-feedback"; + public const string NeedsTeamAttention = "needs-team-attention"; + public const string NeedsTeamTriage = "needs-team-triage"; + public const string NeedsTriage = "needs-triage"; + public const string NoRecentActivity = "no-recent-activity"; + public const string Question = "question"; + public const string ServiceAttention = "Service Attention"; } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/OrgConstants.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/OrgConstants.cs index 78462776a05..548b645f996 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/OrgConstants.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Constants/OrgConstants.cs @@ -10,9 +10,9 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Constants public class OrgConstants { // The Azure is used to check whether or not the use is a member of Azure org. - public static readonly string Azure = "Azure"; + public const string Azure = "Azure"; // The ProductHeaderName is used to register the GitHubClient, specificially, for this // application - public static readonly string ProductHeaderName = "azure-sdk-github-event-processor"; + public const string ProductHeaderName = "azure-sdk-github-event-processor"; } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/IssueProcessing.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/IssueProcessing.cs index 483259fdd85..c48ef5e9580 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/IssueProcessing.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/IssueProcessing.cs @@ -271,10 +271,10 @@ public static void ManualTriageAfterExternalAssignment(GitHubEventClient gitHubE if (issueEventPayload.Action == ActionConstants.Unlabeled) { if (issueEventPayload.Issue.State == ItemState.Open && - LabelUtils.HasLabel(issueEventPayload.Issue.Labels, LabelConstants.CustomerReported) && - (issueEventPayload.Label.Name.Equals(LabelConstants.CXPAttention) || - issueEventPayload.Label.Name.Equals(LabelConstants.ServiceAttention)) && - !LabelUtils.HasLabel(issueEventPayload.Issue.Labels, LabelConstants.NeedsTeamTriage)) + LabelUtils.HasLabel(issueEventPayload.Issue.Labels, LabelConstants.CustomerReported) && + (issueEventPayload.Label.Name.Equals(LabelConstants.CXPAttention) || + issueEventPayload.Label.Name.Equals(LabelConstants.ServiceAttention)) && + !LabelUtils.HasLabel(issueEventPayload.Issue.Labels, LabelConstants.NeedsTeamTriage)) { var issueUpdate = gitHubEventClient.GetIssueUpdate(issueEventPayload.Issue); issueUpdate.AddLabel(LabelConstants.NeedsTeamTriage); diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/PullRequestReviewProcessing.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/PullRequestReviewProcessing.cs index 28747fcc750..7949f638869 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/PullRequestReviewProcessing.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/EventProcessing/PullRequestReviewProcessing.cs @@ -30,7 +30,6 @@ public static async Task ProcessPullRequestReviewEvent(GitHubEventClient gitHubE /// /// Authenticated GitHubEventClient /// PullRequestReviewEventPayload deserialized from the json event payload - /// public static void ResetPullRequestActivity(GitHubEventClient gitHubEventClient, PullRequestReviewEventPayload prReviewEventPayload) { diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs index b0c27ec0d94..2fa7fa29e80 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/GitHubEventClient.cs @@ -264,7 +264,6 @@ public int ComputeNumberOfExpectedUpdates() /// Write the current rate limit and remaining number of transactions. /// /// Optional message to prepend to the rate limit message. - /// public async Task WriteRateLimits(string prependMessage = null) { var miscRateLimit = await GetRateLimits(); @@ -283,7 +282,6 @@ public async Task WriteRateLimits(string prependMessage = null) /// Write the current rate limit and remaining number of transactions. /// /// Optional message to prepend to the rate limit message. - /// public async Task WriteSearchRateLimits(string prependMessage = null) { var miscRateLimit = await GetRateLimits(); @@ -415,7 +413,6 @@ internal IssueUpdate CreateIssueUpdateForPR(PullRequest pullRequest) /// The Id of the repository /// The Issue or PullRequest number /// The comment being created. - /// public void CreateComment(long repositoryId, int issueOrPullRequestNumber, string comment) { GitHubComment gitHubComment = new GitHubComment(repositoryId, issueOrPullRequestNumber, comment); @@ -707,7 +704,6 @@ public virtual async Task QueryIssues(SearchIssuesRequest se /// This method creates a GitHubClient using the GITHUB_TOKEN from the environment for authentication /// /// This is used to generate the User Agent string sent with each request. The name used should represent the product, the GitHub Organization, or the GitHub username that's using Octokit.net (in that order of preference). - /// /// If the product header name is null or empty /// If there is no GITHUB_TOKEN in the environment /// Authenticated GitHubClient diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Program.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Program.cs index 1a7f7c39279..ffdbfc43233 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Program.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Program.cs @@ -38,13 +38,13 @@ static async Task Main(string[] args) await gitHubEventClient.WriteRateLimits("RateLimit at start of execution:"); switch (eventName) { - case EventConstants.issues: + case EventConstants.Issues: { IssueEventGitHubPayload issueEventPayload = serializer.Deserialize(rawJson); await IssueProcessing.ProcessIssueEvent(gitHubEventClient, issueEventPayload); break; } - case EventConstants.issue_comment: + case EventConstants.IssueComment: { IssueCommentPayload issueCommentPayload = serializer.Deserialize(rawJson); // IssueComment events are for both issues and pull requests. If the comment is on a pull request, @@ -60,7 +60,7 @@ static async Task Main(string[] args) break; } - case EventConstants.pull_request_target: + case EventConstants.PullRequestTarget: { // The pull_request, because of the auto_merge processing, requires more than just deserialization of the // the rawJson. @@ -68,18 +68,18 @@ static async Task Main(string[] args) await PullRequestProcessing.ProcessPullRequestEvent(gitHubEventClient, prEventPayload); break; } - case EventConstants.pull_request_review: + case EventConstants.PullRequestReview: { PullRequestReviewEventPayload prReviewEventPayload = serializer.Deserialize(rawJson); await PullRequestReviewProcessing.ProcessPullRequestReviewEvent(gitHubEventClient, prReviewEventPayload); break; } - case EventConstants.schedule: + case EventConstants.Schedule: { if (args.Length < 3) { Console.WriteLine("Error: For scheduled tasks there are three required arguments:"); - Console.WriteLine($" 1. The github.event_name (which will be {EventConstants.schedule} for cron tasks."); + Console.WriteLine($" 1. The github.event_name (which will be {EventConstants.Schedule} for cron tasks."); Console.WriteLine(" 2. The GITHUB_PAYLOAD json file."); Console.WriteLine(" 3. The cron task to run."); Environment.Exit(1); diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CodeOwnerUtils.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CodeOwnerUtils.cs index 0452ce1093c..045981b997b 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CodeOwnerUtils.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CodeOwnerUtils.cs @@ -13,6 +13,9 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Utils /// public class CodeOwnerUtils { + private static readonly string CodeownersFileName = "event-processor.config"; + private static readonly string CodeownersSubDirectory = ".github"; + static List _codeOwnerEntries = null; public static string codeOwnersFilePathOverride = null; @@ -31,7 +34,7 @@ public static string GetCodeOwnersFilePath() } else { - return DirectoryUtils.FindFileInRepository("CODEOWNERS", ".github"); + return DirectoryUtils.FindFileInRepository(CodeownersFileName, CodeownersSubDirectory); } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CommentUtils.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CommentUtils.cs index ed87459aa81..9c4e7ca6aba 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CommentUtils.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/CommentUtils.cs @@ -11,11 +11,11 @@ namespace Azure.Sdk.Tools.GitHubEventProcessor.Utils public class CommentUtils { /// - /// + /// Common code to ensure comment text is searched the exact same way while preventing duplicate code + /// in multiple places. /// - /// - /// - /// + /// The full comment test from IssueCommentPayload.Comment.Body + /// The string to search for in the comments internal static bool CommentContainsText(string comment, string textToLookFor) { // Why is this using IndexOf instead of string.Contains? @@ -25,11 +25,7 @@ internal static bool CommentContainsText(string comment, string textToLookFor) // Also, the strings being looked for will always be in English, matching what's in the // CommentConstants class which is why OrdinalIgnoreCase instead of the cultural string // comparisons. - if (comment.IndexOf(textToLookFor, StringComparison.OrdinalIgnoreCase) >= 0) - { - return true; - } - return false; + return comment.IndexOf(textToLookFor, StringComparison.OrdinalIgnoreCase) >= 0; } } } diff --git a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/LabelUtils.cs b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/LabelUtils.cs index f65fb91f36d..f4562ba8009 100644 --- a/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/LabelUtils.cs +++ b/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor/Utils/LabelUtils.cs @@ -16,19 +16,17 @@ public class LabelUtils /// true if the label exists, false otherwise public static bool HasLabel(IReadOnlyList