nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: palantir/policy-bot
Pull request #188 (2020-05-12 21:01:53)

Use unqualified names in team assignment
Because you can only assign teams from the organization, the API expects
to get unqualified team slugs as input.

cc @AdamDeHovitz

ajlake: 👍 

Patch:
diff --git a/policy/reviewer/reviewer.go b/policy/reviewer/reviewer.go
index 1b7329a..6430eb1 100644
--- a/policy/reviewer/reviewer.go
+++ b/policy/reviewer/reviewer.go
@@ -142,7 +142,7 @@ func getPossibleReviewers(prctx pull.Context, users map[string]struct{}, collabo
 func stripOrg(teamWithOrg string) (string, error) {
 	split := strings.Split(teamWithOrg, "/")
 	if len(split) < 0 {
-		return "", fmt.Errorf("Expected org with team: '%s'", teamWithOrg)
+		return "", fmt.Errorf("expected org with team: '%s'", teamWithOrg)
 	}
 	return split[1], nil
 }
@@ -224,12 +224,12 @@ func SelectReviewers(ctx context.Context, prctx pull.Context, result common.Resu
 				return nil, nil, err
 			}
 			for team := range allTeamsWithUsers {
-				formattedTeam, err := stripOrg(team)
+				slug, err := stripOrg(team)
 				if err != nil {
 					return nil, nil, err
 				}
-				if _, ok := permissionedTeams[formattedTeam]; ok {
-					possibleTeams = append(possibleTeams, team)
+				if _, ok := permissionedTeams[slug]; ok {
+					possibleTeams = append(possibleTeams, slug)
 				}
 			}
 			logger.Debug().Msgf("Found %d total teams; requesting teams", len(possibleTeams))


Test patch:
diff --git a/policy/reviewer/reviewer_test.go b/policy/reviewer/reviewer_test.go
index 4734a63..d647aea 100644
--- a/policy/reviewer/reviewer_test.go
+++ b/policy/reviewer/reviewer_test.go
@@ -114,7 +114,7 @@ func TestSelectAdminTeam(t *testing.T) {
 	reviewers, teams, err := SelectReviewers(context.Background(), prctx, results, r)
 	require.NoError(t, err)
 	require.Len(t, teams, 1, "admin team should be selected")
-	require.Contains(t, teams, "everyone/team-admin", "admin team seleted")
+	require.Contains(t, teams, "team-admin", "admin team seleted")
 
 	require.Len(t, reviewers, 0, "policy should request no people")
 }
@@ -166,7 +166,7 @@ func TestSelectReviewers_Team_teams(t *testing.T) {
 	reviewers, teams, err := SelectReviewers(context.Background(), prctx, results, r)
 	require.NoError(t, err)
 	require.Len(t, teams, 1, "one team should be returned")
-	require.Contains(t, teams, "everyone/team-write", "team-write should be selected")
+	require.Contains(t, teams, "team-write", "team-write should be selected")
 	require.Len(t, reviewers, 2, "policy should request 2 people")
 	require.Contains(t, reviewers, "review-approver", "at least review-approver must be selected")
 	require.NotContains(t, reviewers, "user-team-write", "user-team-write should not be selected")
Repository: palantir/policy-bot
Pull request #275 (2021-03-26 09:27:33)

Clarify PR Title Matching Error
When viewing this check in the github UI, it's not obvious what "Title" is referring to. Adding "PR" to clarify that it's referring to the title of the PR itself that needs to be updated.


Patch:
diff --git a/policy/predicate/title.go b/policy/predicate/title.go
index 530b4b4..a120bcd 100644
--- a/policy/predicate/title.go
+++ b/policy/predicate/title.go
@@ -33,13 +33,13 @@ func (pred Title) Evaluate(ctx context.Context, prctx pull.Context) (bool, strin
 
 	if len(pred.Matches) > 0 {
 		if anyMatches(pred.Matches, title) {
-			return true, "Title matches a Match pattern", nil
+			return true, "PR Title matches a Match pattern", nil
 		}
 	}
 
 	if len(pred.NotMatches) > 0 {
 		if !anyMatches(pred.NotMatches, title) {
-			return true, "Title doesn't match a NotMatch pattern", nil
+			return true, "PR Title doesn't match a NotMatch pattern", nil
 		}
 	}
 


Test patch:
diff --git a/policy/disapproval/disapprove_test.go b/policy/disapproval/disapprove_test.go
index b276a4a..8870e49 100644
--- a/policy/disapproval/disapprove_test.go
+++ b/policy/disapproval/disapprove_test.go
@@ -162,7 +162,7 @@ func TestIsDisapproved(t *testing.T) {
 			},
 		}
 
-		assertDisapproved(t, p, "Title doesn't match a NotMatch pattern")
+		assertDisapproved(t, p, "PR Title doesn't match a NotMatch pattern")
 	})
 
 	t.Run("predicateDoesNotDisapprove", func(t *testing.T) {