resolve first todos
This commit is contained in:
parent
ea3c106944
commit
e3ebcf47d3
28
main.go
28
main.go
@ -23,6 +23,8 @@ type Cache struct {
|
|||||||
pullBaseBranch string `json:"pullBaseBranch"`
|
pullBaseBranch string `json:"pullBaseBranch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const perPage = 10
|
||||||
|
|
||||||
func loadCache() (cache *Cache) {
|
func loadCache() (cache *Cache) {
|
||||||
// default values
|
// default values
|
||||||
cache = &Cache{
|
cache = &Cache{
|
||||||
@ -115,11 +117,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
repoList = append(repoList, repos...)
|
repoList = append(repoList, repos...)
|
||||||
|
|
||||||
if len(repos) < 10 {
|
if len(repos) < 10 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
page++
|
page++
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
@ -136,10 +136,24 @@ func main() {
|
|||||||
func threatRepo(baseBranchRule glob.Glob, client *gitlab.Client, repo *gitlab.Project) {
|
func threatRepo(baseBranchRule glob.Glob, client *gitlab.Client, repo *gitlab.Project) {
|
||||||
fmt.Printf("Handle Repository '%s'\n", repo.Name)
|
fmt.Printf("Handle Repository '%s'\n", repo.Name)
|
||||||
|
|
||||||
// TODO: handle pagination
|
var branchList []*gitlab.Branch
|
||||||
branchList, _, err := client.Branches.ListBranches(repo.ID, nil)
|
var page = 1
|
||||||
if err != nil {
|
for {
|
||||||
error(10, "Could not obtain branch list from '%s': %v\n", repo.Name, err)
|
bL, _, err := client.Branches.ListBranches(repo.ID, &gitlab.ListBranchesOptions{
|
||||||
|
ListOptions: gitlab.ListOptions{
|
||||||
|
Page: page,
|
||||||
|
PerPage: perPage,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
error(10, "Could not obtain branch list from '%s': %v\n", repo.Name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
branchList = append(branchList, bL...)
|
||||||
|
if len(bL) < 10 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
page++
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" found %d branches:", len(branchList))
|
fmt.Printf(" found %d branches:", len(branchList))
|
||||||
@ -181,7 +195,7 @@ func threatRepo(baseBranchRule glob.Glob, client *gitlab.Client, repo *gitlab.Pr
|
|||||||
if len(pullList) == 0 {
|
if len(pullList) == 0 {
|
||||||
fmt.Printf(" no existing pull for %s, creating one ...\n", baseBranch.Name)
|
fmt.Printf(" no existing pull for %s, creating one ...\n", baseBranch.Name)
|
||||||
pull, _, err := client.MergeRequests.CreateMergeRequest(repo.ID, &gitlab.CreateMergeRequestOptions{
|
pull, _, err := client.MergeRequests.CreateMergeRequest(repo.ID, &gitlab.CreateMergeRequestOptions{
|
||||||
Title: optString(fmt.Sprintf("%s <- %s", repo.DefaultBranch, baseBranch.Name)), // TODO: better title (required)
|
Title: optString(fmt.Sprintf("%s <- %s", repo.DefaultBranch, baseBranch.Name)),
|
||||||
Description: optString("Auto created by https://code.obermui.de/6543/GitLab_MergeDevel2Default"),
|
Description: optString("Auto created by https://code.obermui.de/6543/GitLab_MergeDevel2Default"),
|
||||||
SourceBranch: &baseBranch.Name,
|
SourceBranch: &baseBranch.Name,
|
||||||
TargetBranch: &repo.DefaultBranch,
|
TargetBranch: &repo.DefaultBranch,
|
||||||
|
Loading…
Reference in New Issue
Block a user