Skip to content

Commit 5995d96

Browse files
kerobbiSamMorrowDrums
authored andcommitted
remove get_check_runs gate
1 parent 7f838a9 commit 5995d96

2 files changed

Lines changed: 4 additions & 63 deletions

File tree

pkg/github/pullrequests.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Possible options:
152152
result, err := GetIssueComments(ctx, client, deps, owner, repo, pullNumber, pagination)
153153
return attachIFC(result), nil, err
154154
case "get_check_runs":
155-
result, err := GetPullRequestCheckRuns(ctx, client, deps, owner, repo, pullNumber, pagination)
155+
result, err := GetPullRequestCheckRuns(ctx, client, owner, repo, pullNumber, pagination)
156156
return attachIFC(result), nil, err
157157
default:
158158
return utils.NewToolResultError(fmt.Sprintf("unknown method: %s", method)), nil, nil
@@ -315,7 +315,7 @@ func GetPullRequestStatus(ctx context.Context, client *github.Client, owner, rep
315315
return utils.NewToolResultText(string(r)), nil
316316
}
317317

318-
func GetPullRequestCheckRuns(ctx context.Context, client *github.Client, deps ToolDependencies, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {
318+
func GetPullRequestCheckRuns(ctx context.Context, client *github.Client, owner, repo string, pullNumber int, pagination PaginationParams) (*mcp.CallToolResult, error) {
319319
// First get the PR to get the head SHA
320320
pr, resp, err := client.PullRequests.Get(ctx, owner, repo, pullNumber)
321321
if err != nil {
@@ -335,16 +335,6 @@ func GetPullRequestCheckRuns(ctx context.Context, client *github.Client, deps To
335335
return ghErrors.NewGitHubAPIStatusErrorResponse(ctx, "failed to get pull request", resp, body), nil
336336
}
337337

338-
if deps.GetFlags(ctx).LockdownMode {
339-
cache, err := deps.GetRepoAccessCache(ctx)
340-
if err != nil {
341-
return nil, fmt.Errorf("failed to get repo access cache: %w", err)
342-
}
343-
if restricted, err := authorLockdownResult(ctx, cache, owner, repo, pr.GetUser().GetLogin(), lockdownPullRequestRestrictedMessage); restricted != nil || err != nil {
344-
return restricted, err
345-
}
346-
}
347-
348338
// Get check runs for the head SHA
349339
opts := &github.ListCheckRunsOptions{
350340
ListOptions: github.ListOptions{

pkg/github/pullrequests_test.go

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,8 +1772,6 @@ func Test_GetPullRequestCheckRuns(t *testing.T) {
17721772
expectError bool
17731773
expectedCheckRuns *github.ListCheckRunsResults
17741774
expectedErrMsg string
1775-
lockdownEnabled bool
1776-
restPermission string
17771775
}{
17781776
{
17791777
name: "successful check runs fetch",
@@ -1825,64 +1823,17 @@ func Test_GetPullRequestCheckRuns(t *testing.T) {
18251823
expectError: true,
18261824
expectedErrMsg: "failed to get check runs",
18271825
},
1828-
{
1829-
name: "lockdown enabled - author lacks push access",
1830-
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
1831-
GetReposPullsByOwnerByRepoByPullNumber: mockResponse(t, http.StatusOK, &github.PullRequest{
1832-
Number: github.Ptr(42),
1833-
Head: &github.PullRequestBranch{SHA: github.Ptr("abcd1234")},
1834-
User: &github.User{Login: github.Ptr("reader")},
1835-
}),
1836-
}),
1837-
requestArgs: map[string]any{
1838-
"method": "get_check_runs",
1839-
"owner": "owner",
1840-
"repo": "repo",
1841-
"pullNumber": float64(42),
1842-
},
1843-
lockdownEnabled: true,
1844-
restPermission: "read",
1845-
expectError: true,
1846-
expectedErrMsg: "access to pull request is restricted by lockdown mode",
1847-
},
1848-
{
1849-
name: "lockdown enabled - author has push access",
1850-
mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{
1851-
GetReposPullsByOwnerByRepoByPullNumber: mockResponse(t, http.StatusOK, &github.PullRequest{
1852-
Number: github.Ptr(42),
1853-
Head: &github.PullRequestBranch{SHA: github.Ptr("abcd1234")},
1854-
User: &github.User{Login: github.Ptr("writer")},
1855-
}),
1856-
GetReposCommitsCheckRunsByOwnerByRepoByRef: mockResponse(t, http.StatusOK, mockCheckRuns),
1857-
}),
1858-
requestArgs: map[string]any{
1859-
"method": "get_check_runs",
1860-
"owner": "owner",
1861-
"repo": "repo",
1862-
"pullNumber": float64(42),
1863-
},
1864-
lockdownEnabled: true,
1865-
restPermission: "write",
1866-
expectError: false,
1867-
expectedCheckRuns: mockCheckRuns,
1868-
},
18691826
}
18701827

18711828
for _, tc := range tests {
18721829
t.Run(tc.name, func(t *testing.T) {
18731830
// Setup client with mock
18741831
client := mustNewGHClient(t, tc.mockedClient)
18751832
serverTool := PullRequestRead(translations.NullTranslationHelper)
1876-
1877-
var restClient *github.Client
1878-
if tc.lockdownEnabled {
1879-
restClient = mockRESTPermissionServer(t, tc.restPermission, nil)
1880-
}
1881-
18821833
deps := BaseDeps{
18831834
Client: client,
1884-
RepoAccessCache: stubRepoAccessCache(restClient, 5*time.Minute),
1885-
Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": tc.lockdownEnabled}),
1835+
RepoAccessCache: stubRepoAccessCache(nil, 5*time.Minute),
1836+
Flags: stubFeatureFlags(map[string]bool{"lockdown-mode": false}),
18861837
}
18871838
handler := serverTool.Handler(deps)
18881839

0 commit comments

Comments
 (0)