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
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
59 changes: 32 additions & 27 deletions cli/gh-pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,44 +60,49 @@ func (gr githubRepo) PrTests(pri int, filterRegExStr, splitTestsAt string) (*map
}

clog.Log.Tracef("listing files...")
files, _, err := client.PullRequests.ListFiles(ctx, gr.Owner, gr.Name, pri, nil)
if err != nil {
return nil, err
}

// filter out uninteresting files and convert non test files to test files and only retain unique
filesFiltered := map[string]bool{}
clog.Log.Debugf(" filtering files (%s)", filterRegExStr)
for _, f := range files {
if f.Filename == nil {
continue
for i := 0; ; i++ {
files, _, err := client.PullRequests.ListFiles(ctx, gr.Owner, gr.Name, pri, &github.ListOptions{PerPage: 100, Page: i})
if len(files) == 0 {
break
}
if err != nil {
return nil, err
}

name := *f.Filename
clog.Log.Debugf(" %v", *f.Filename)

// if in service package mode skip some files
if strings.Contains(name, "/services/") {
if strings.Contains(name, "/client/") || strings.Contains(name, "/parse/") || strings.Contains(name, "/validate/") {
// filter out uninteresting files and convert non test files to test files and only retain unique
clog.Log.Debugf(" filtering files (%s)", filterRegExStr)
for _, f := range files {
if f.Filename == nil {
continue
}

if strings.HasSuffix(name, "registration.go") || strings.HasSuffix(name, "resourceids.go") {
name := *f.Filename
clog.Log.Debugf(" %v", *f.Filename)

// if in service package mode skip some files
if strings.Contains(name, "/services/") {
if strings.Contains(name, "/client/") || strings.Contains(name, "/parse/") || strings.Contains(name, "/validate/") {
continue
}

if strings.HasSuffix(name, "registration.go") || strings.HasSuffix(name, "resourceids.go") {
continue
}
}

if strings.HasSuffix(name, "_test.go") {
filesFiltered[name] = true
continue
}
}

if strings.HasSuffix(name, "_test.go") {
filesFiltered[name] = true
continue
}
if !fileRegEx.MatchString(name) {
continue
}

if !fileRegEx.MatchString(name) {
continue
f := strings.Replace(name, ".go", "_test.go", 1)
filesFiltered[f] = true
}

f := strings.Replace(name, ".go", "_test.go", 1)
filesFiltered[f] = true
}
clog.Log.Debugf(" FOUND %d", len(filesFiltered))

Expand Down
Loading