Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle PR files pages #60

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions cli/gh-pr-filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ func GetFilterForMilestone(milestoneRaw string) *Filter {
PR: func(pr github.PullRequest) (bool, error) {
milestone := pr.GetMilestone().GetTitle()

// nolint:gocritic
//nolint:gocritic
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh-pr-filters.go:92:4: directive // nolint:gocritic should be written without leading space as //nolint:gocritic (nolintlint)

                        // nolint:gocritic
                        ^

if strings.EqualFold(filterMilestone, milestone) && !negate {
c.Printf(" milestone: <green>%s</> <gray>(%s)</>\n", filterMilestone, milestone)
return true, nil
} else if negate {
c.Printf(" milestone: <green>-%s</> <gray>(%s)</>\n", filterMilestone, milestone)
return true, nil
} else {
//revive:disable:indent-error-flow
c.Printf(" milestone: <red>%s</> <gray>(%s)</>\n", filterMilestone, milestone)
return false, nil
}
Comment on lines 99 to 103
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh-pr-filters.go:99:11: indent-error-flow: if block ends with a return statement, so drop this else and outdent its block (revive)

                        } else {
                                c.Printf("    milestone: <red>%s</> <gray>(%s)</>\n", filterMilestone, milestone)
                                return false, nil
                        }

Expand Down Expand Up @@ -207,7 +208,7 @@ func GetFilterForLabels(labels []string, and bool) *Filter {
for filterLabel, negate := range filterLabelMap {
_, found := labelMap[filterLabel]

// nolint:gocritic
//nolint:gocritic
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh-pr-filters.go:210:5: directive // nolint:gocritic should be written without leading space as //nolint:gocritic (nolintlint)

                                // nolint:gocritic
                                ^

if found && !negate {
orPass = true
c.Printf(" <green>%s</>", filterLabel)
Expand Down
9 changes: 4 additions & 5 deletions cli/gh-pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (f FlagData) GetPrTests(pr int) (*map[string][]string, error) {
}

// todo break this apart - get/check PR state, get files, filter/process files, get tests, get services.
func (gr githubRepo) PrTests(pri int, filterRegExStr, splitTestsAt string) (*map[string][]string, error) {
func (gr GithubRepo) PrTests(pri int, filterRegExStr, splitTestsAt string) (*map[string][]string, error) {
client, ctx := gr.NewClient()
httpClient := chttp.NewHTTPClient("HTTP")

Expand Down Expand Up @@ -94,7 +94,7 @@ func (gr githubRepo) PrTests(pri int, filterRegExStr, splitTestsAt string) (*map
}

// todo thread ctx
// nolint: noctx
//nolint: noctx
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh-pr.go:97:3: directive // nolint: noctx should be written without leading space as //nolint: noctx (nolintlint)

                // nolint: noctx
                ^

resp, err := httpClient.Get(*fileContents.DownloadURL)
if err != nil {
return nil, fmt.Errorf("downloading file (%s): %w", f, err)
Expand Down Expand Up @@ -151,7 +151,7 @@ func (gr githubRepo) PrTests(pri int, filterRegExStr, splitTestsAt string) (*map
return &serviceTests, nil
}

func (gr githubRepo) ListAllPullRequestFiles(pri int, cb func([]*github.CommitFile, *github.Response) error) error {
func (gr GithubRepo) ListAllPullRequestFiles(pri int, cb func([]*github.CommitFile, *github.Response) error) error {
client, ctx := gr.NewClient()

opts := &github.ListOptions{
Expand Down Expand Up @@ -179,7 +179,7 @@ func (gr githubRepo) ListAllPullRequestFiles(pri int, cb func([]*github.CommitFi
return nil
}

func (gr githubRepo) GetAllPullRequestFiles(pri int, filterRegExStr string) (*map[string]struct{}, error) {
func (gr GithubRepo) GetAllPullRequestFiles(pri int, filterRegExStr string) (*map[string]struct{}, error) {
result := make(map[string]struct{})
filterRegEx := regexp.MustCompile(filterRegExStr)

Expand Down Expand Up @@ -218,7 +218,6 @@ func (gr githubRepo) GetAllPullRequestFiles(pri int, filterRegExStr string) (*ma

return nil
})

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh-pr.go:221: File is not gofumpt-ed (gofumpt)

if err != nil {
return nil, fmt.Errorf("failed to get all files for %s/%s/pull/%d: %w", gr.Owner, gr.Name, pri, err)
}
Expand Down
6 changes: 3 additions & 3 deletions cli/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
)

// wrap the common gh lib shared with my other tools. splits common GH code from this CLI tool's specific tooling code
type githubRepo struct {
type GithubRepo struct {
gh.Repo
}

func (f FlagData) NewRepo() githubRepo {
func (f FlagData) NewRepo() GithubRepo {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/gh.go:15:29: unexported-return: exported method NewRepo returns unexported type cli.githubRepo, which can be annoying to use (revive)

func (f FlagData) NewRepo() githubRepo {
                            ^

ownerrepo := f.GH.Repo

parts := strings.Split(ownerrepo, "/")
Expand All @@ -24,5 +24,5 @@ func (f FlagData) NewRepo() githubRepo {
token := f.GH.Token
clog.Log.Debugf("new gh: %s@%s/%s", token, owner, repo)

return githubRepo{gh.NewRepo(owner, repo, token)}
return GithubRepo{gh.NewRepo(owner, repo, token)}
}
6 changes: 3 additions & 3 deletions cli/tc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
)

// wrap the common gh lib shared with my other tools. splits common GH code from this CLI tool's specific tooling code
type tcServer struct {
type TcServer struct {
tc.Server
}

func (f FlagData) NewServer() tcServer {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli/tc.go:12:31: unexported-return: exported method NewServer returns unexported type cli.tcServer, which can be annoying to use (revive)

func (f FlagData) NewServer() tcServer {
                              ^

return tcServer{tc.NewServer(f.TC.ServerURL, f.TC.Token, f.TC.User, f.TC.Pass)}
func (f FlagData) NewServer() TcServer {
return TcServer{tc.NewServer(f.TC.ServerURL, f.TC.Token, f.TC.User, f.TC.Pass)}
}
10 changes: 5 additions & 5 deletions lib/chttp/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ func NewHTTPClient(name string) *http.Client {
}
}

type transport struct {
type Transport struct {
name string
transport http.RoundTripper
}

func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
reqData, err := httputil.DumpRequestOut(req, true)

if err == nil {
Expand All @@ -47,8 +47,8 @@ func (t *transport) RoundTrip(req *http.Request) (*http.Response, error) {
return resp, nil
}

func NewTransport(name string, t http.RoundTripper) *transport {
return &transport{name, t}
func NewTransport(name string, t http.RoundTripper) *Transport {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/chttp/http.go:50:53: unexported-return: exported func NewTransport returns unexported type *chttp.transport, which can be annoying to use (revive)

func NewTransport(name string, t http.RoundTripper) *transport {
                                                    ^

return &Transport{name, t}
}

// prettyPrintJSON iterates through a []byte line-by-line,
Expand All @@ -58,7 +58,7 @@ func prettyPrintJSON(b []byte) string {
for i, p := range parts {
if b := []byte(p); json.Valid(b) {
var out bytes.Buffer
// nolint:errcheck
//nolint:errcheck
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/chttp/http.go:61:4: directive // nolint:errcheck should be written without leading space as //nolint:errcheck (nolintlint)

                        // nolint:errcheck
                        ^

json.Indent(&out, b, "", " ")
parts[i] = out.String()
}
Expand Down