Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Code Ownership & Review Assignment Tool - GitHub CODEOWNERS but better

[![Go Report Card](https://goreportcard.com/badge/github.com/multimediallc/codeowners-plus)](https://goreportcard.com/report/github.com/multimediallc/codeowners-plus?kill_cache=1)
[![Tests](https://github.com/multimediallc/codeowners-plus/actions/workflows/go.yml/badge.svg)](https://github.com/multimediallc/codeowners-plus/actions/workflows/go.yml)
![Coverage](https://img.shields.io/badge/Coverage-82.7%25-brightgreen)
![Coverage](https://img.shields.io/badge/Coverage-82.6%25-brightgreen)
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.26.4
require (
github.com/bmatcuk/doublestar/v4 v4.10.0
github.com/boyter/gocodewalker v1.5.1
github.com/google/go-github/v86 v86.0.0
github.com/google/go-github/v89 v89.0.0
github.com/pelletier/go-toml/v2 v2.4.3
github.com/sourcegraph/go-diff v0.8.0
github.com/urfave/cli/v3 v3.10.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/go-github/v86 v86.0.0 h1:S/6aANJhwRm8EQmGKVML3j41yq0h2BsTP8FnDkO7kcA=
github.com/google/go-github/v86 v86.0.0/go.mod h1:zKv1l4SwDXNFMGByi2FWkq71KwSXqj/eQRZuqtmcot8=
github.com/google/go-github/v89 v89.0.0 h1:35bEK5XoEcF3PZrlVbl9XN63f5BcJRA/UGkxeC9xPg0=
github.com/google/go-github/v89 v89.0.0/go.mod h1:QLcbU0ipeAqQuR5KSg8c2lql4Qk1EwJ2dWz/0rP4Nho=
github.com/google/go-querystring v1.2.0 h1:yhqkPbu2/OH+V9BfpCVPZkNmUXhb2gBxJArfhIxNtP0=
github.com/google/go-querystring v1.2.0/go.mod h1:8IFJqpSRITyJ8QhQ13bmbeMBDfmeEJZD5A0egEOmkqU=
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
Expand Down
5 changes: 4 additions & 1 deletion internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func New(cfg Config) (*App, error) {
owner := repoSplit[0]
repo := repoSplit[1]

client := gh.NewClient(owner, repo, cfg.Token)
client, err := gh.NewClient(owner, repo, cfg.Token)
if err != nil {
return nil, err
}
app := &App{
config: &cfg,
client: client,
Expand Down
2 changes: 1 addition & 1 deletion internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/google/go-github/v86/github"
"github.com/google/go-github/v89/github"
owners "github.com/multimediallc/codeowners-plus/internal/config"
"github.com/multimediallc/codeowners-plus/internal/git"
gh "github.com/multimediallc/codeowners-plus/internal/github"
Expand Down
11 changes: 7 additions & 4 deletions internal/github/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/google/go-github/v86/github"
"github.com/google/go-github/v89/github"
"github.com/multimediallc/codeowners-plus/internal/git"
"github.com/multimediallc/codeowners-plus/pkg/codeowners"
f "github.com/multimediallc/codeowners-plus/pkg/functional"
Expand Down Expand Up @@ -69,8 +69,11 @@ type GHClient struct {
infoBuffer io.Writer
}

func NewClient(owner, repo, token string) Client {
client := github.NewClient(nil).WithAuthToken(token)
func NewClient(owner, repo, token string) (Client, error) {
client, err := github.NewClient(github.WithAuthToken(token))
if err != nil {
return nil, err
}
return &GHClient{
context.Background(),
owner,
Expand All @@ -82,7 +85,7 @@ func NewClient(owner, repo, token string) Client {
nil,
io.Discard,
io.Discard,
}
}, nil
}

func (gh *GHClient) PR() *github.PullRequest {
Expand Down
20 changes: 13 additions & 7 deletions internal/github/gh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import (
"io"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"testing"
"time"

"github.com/google/go-github/v86/github"
"github.com/google/go-github/v89/github"
"github.com/multimediallc/codeowners-plus/pkg/codeowners"
f "github.com/multimediallc/codeowners-plus/pkg/functional"
)
Expand Down Expand Up @@ -323,7 +322,11 @@ func TestIsSubstringInComments(t *testing.T) {
}

func TestNewGithubClient(t *testing.T) {
client, ok := NewClient("owner", "repo", "token").(*GHClient)
c, err := NewClient("owner", "repo", "token")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
client, ok := c.(*GHClient)
if !ok {
t.Fatalf("Expected client to be of type *GHClient, got %T", client)
}
Expand Down Expand Up @@ -582,12 +585,11 @@ func TestNilCommentsErr(t *testing.T) {
func mockServerAndClient(t *testing.T) (*http.ServeMux, *httptest.Server, *GHClient) {
mux := http.NewServeMux()
server := httptest.NewServer(mux)
client := github.NewClient(nil)
baseURL, err := url.Parse(server.URL + "/")
baseURL := server.URL + "/"
client, err := github.NewClient(github.WithURLs(&baseURL, &baseURL))
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
client.BaseURL = baseURL
gh := &GHClient{
ctx: context.Background(),
owner: "test-owner",
Expand Down Expand Up @@ -1462,7 +1464,11 @@ func TestContainsValidBypassApproval(t *testing.T) {
}

func TestContainsValidBypassApprovalNoPR(t *testing.T) {
gh := NewClient("test-owner", "test-repo", "test-token").(*GHClient)
c, err := NewClient("test-owner", "test-repo", "test-token")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
gh := c.(*GHClient)

result, err := gh.ContainsValidBypassApproval([]string{})

Expand Down
Loading