You've already forked mpbot-github
mirror of
https://github.com/macports/mpbot-github.git
synced 2026-03-31 14:46:03 -07:00
24 lines
592 B
Go
24 lines
592 B
Go
package githubapi
|
|
|
|
import (
|
|
"context"
|
|
"github.com/google/go-github/github"
|
|
"regexp"
|
|
)
|
|
|
|
func ListChangedPorts(number int) []string {
|
|
client := github.NewClient(nil)
|
|
files, _, err := client.PullRequests.ListFiles(context.Background(), "macports-staging", "macports-ports", number, nil)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
ports := make([]string, 0, 1)
|
|
portfileRegexp := regexp.MustCompile(`[^\._/][^/]*/([^/]+)/Portfile`)
|
|
for _, file := range files {
|
|
if match := portfileRegexp.FindStringSubmatch(*file.Filename); match != nil {
|
|
ports = append(ports, match[1])
|
|
}
|
|
}
|
|
return ports
|
|
}
|