Skip to content

Commit eda6b28

Browse files
committed
Fix logic after vibe coding
1 parent c0edac0 commit eda6b28

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

pkg/github/issues.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ func GetIssueComments(ctx context.Context, client *github.Client, cache *lockdow
400400
}
401401
// Do not filter content for private repositories
402402
if isPrivate {
403+
filteredComments = comments
403404
break
404405
}
405406
if hasPushAccess {
@@ -464,6 +465,7 @@ func GetSubIssues(ctx context.Context, client *github.Client, cache *lockdown.Re
464465
}
465466
// Repo is private, do not filter content
466467
if isPrivate {
468+
filteredSubIssues = subIssues
467469
break
468470
}
469471
if hasPushAccess {

pkg/github/pullrequests.go

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,25 @@ func GetPullRequestReviewComments(ctx context.Context, client *github.Client, ca
297297
if cache == nil {
298298
return nil, fmt.Errorf("lockdown cache is not configured")
299299
}
300-
if len(comments) > 0 {
301-
login := comments[0].GetUser().GetLogin()
302-
if login != "" {
303-
isPrivate, hasPushAccess, err := cache.GetRepoAccessInfo(ctx, login, owner, repo)
304-
if err != nil {
305-
return nil, fmt.Errorf("failed to check content removal: %w", err)
306-
}
307-
if !isPrivate && !hasPushAccess {
308-
return mcp.NewToolResultError("access to pull request review comments is restricted by lockdown mode"), nil
309-
}
300+
filteredComments := make([]*github.PullRequestComment, 0, len(comments))
301+
for _, comment := range comments {
302+
user := comment.GetUser()
303+
if user == nil {
304+
continue
305+
}
306+
isPrivate, hasPushAccess, err := cache.GetRepoAccessInfo(ctx, user.GetLogin(), owner, repo)
307+
if err != nil {
308+
return mcp.NewToolResultError(fmt.Sprintf("failed to check lockdown mode: %v", err)), nil
309+
}
310+
if isPrivate {
311+
filteredComments = comments
312+
break
313+
}
314+
if hasPushAccess {
315+
filteredComments = append(filteredComments, comment)
310316
}
311317
}
318+
comments = filteredComments
312319
}
313320

314321
r, err := json.Marshal(comments)
@@ -342,16 +349,21 @@ func GetPullRequestReviews(ctx context.Context, client *github.Client, cache *lo
342349
if cache == nil {
343350
return nil, fmt.Errorf("lockdown cache is not configured")
344351
}
345-
if len(reviews) > 0 {
346-
login := reviews[0].GetUser().GetLogin()
352+
filteredReviews := make([]*github.PullRequestReview, 0, len(reviews))
353+
for _, review := range reviews {
354+
login := review.GetUser().GetLogin()
347355
if login != "" {
348356
isPrivate, hasPushAccess, err := cache.GetRepoAccessInfo(ctx, login, owner, repo)
349357
if err != nil {
350-
return nil, fmt.Errorf("failed to check content removal: %w", err)
358+
return nil, fmt.Errorf("failed to check lockdown mode: %w", err)
359+
}
360+
if isPrivate {
361+
filteredReviews = reviews
351362
}
352-
if !isPrivate && !hasPushAccess {
353-
return mcp.NewToolResultError("access to pull request reviews is restricted by lockdown mode"), nil
363+
if hasPushAccess {
364+
filteredReviews = append(filteredReviews, review)
354365
}
366+
reviews = filteredReviews
355367
}
356368
}
357369
}

0 commit comments

Comments
 (0)