1
1
mirror of https://github.com/cooperspencer/gickup synced 2025-04-30 18:27:56 +02:00

added function to exclude repos

This commit is contained in:
Andreas Wachter 2021-12-02 18:43:39 +01:00
parent 6972bbd002
commit 64b5570434
4 changed files with 55 additions and 20 deletions

@ -20,19 +20,8 @@ jobs:
with:
go-version: 1.17
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.3
with:
# Artifact name
name: gickup
# A file, directory or wildcard pattern that describes what to upload
path: gickup
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
@ -42,4 +31,10 @@ jobs:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
name: gickup
path: dist/*

3
.gitignore vendored

@ -1,2 +1,3 @@
bla.conf
gickup
gickup
conf.yml

38
main.go

@ -55,6 +55,14 @@ func ReadConfigfile(configfile string) *Conf {
return &t
}
func GetExcludedMap(excludes []string) map[string]bool {
excludemap := make(map[string]bool)
for _, exclude := range excludes {
excludemap[exclude] = true
}
return excludemap
}
func Locally(repo Repo, l Local) {
if _, err := os.Stat(l.Path); os.IsNotExist(err) {
err := os.MkdirAll(l.Path, 0777)
@ -288,7 +296,12 @@ func getGithub(conf *Conf) []Repo {
i++
}
exclude := GetExcludedMap(repo.Exclude)
for _, r := range githubrepos {
if exclude[*r.Name] {
continue
}
repos = append(repos, Repo{Name: r.GetName(), Url: r.GetCloneURL(), SshUrl: r.GetSSHURL(), Token: repo.Token, Defaultbranch: r.GetDefaultBranch(), Origin: repo})
}
}
@ -326,7 +339,12 @@ func getGitea(conf *Conf) []Repo {
i++
}
exclude := GetExcludedMap(repo.Exclude)
for _, r := range gitearepos {
if exclude[r.Name] {
continue
}
repos = append(repos, Repo{Name: r.Name, Url: r.CloneURL, SshUrl: r.SSHURL, Token: repo.Token, Defaultbranch: r.DefaultBranch, Origin: repo})
}
}
@ -343,7 +361,12 @@ func getGogs(conf *Conf) []Repo {
log.Panic().Str("stage", "gogs").Str("url", repo.Url).Msg(err.Error())
}
exclude := GetExcludedMap(repo.Exclude)
for _, r := range gogsrepos {
if exclude[r.Name] {
continue
}
repos = append(repos, Repo{Name: r.Name, Url: r.CloneURL, SshUrl: r.SSHURL, Token: repo.Token, Defaultbranch: r.DefaultBranch, Origin: repo})
}
}
@ -387,7 +410,13 @@ func getGitlab(conf *Conf) []Repo {
}
}
}
exclude := GetExcludedMap(repo.Exclude)
for _, r := range gitlabrepos {
if exclude[r.Name] {
continue
}
repos = append(repos, Repo{Name: r.Name, Url: r.HTTPURLToRepo, SshUrl: r.SSHURLToRepo, Token: repo.Token, Defaultbranch: r.DefaultBranch, Origin: repo})
}
groups, _, err := client.Groups.ListGroups(&gitlab.ListGroupsOptions{})
@ -416,6 +445,9 @@ func getGitlab(conf *Conf) []Repo {
}
}
for _, r := range gitlabgrouprepos {
if exclude[r.Name] {
continue
}
repos = append(repos, Repo{Name: r.Name, Url: r.HTTPURLToRepo, SshUrl: r.SSHURLToRepo, Token: repo.Token, Defaultbranch: r.DefaultBranch, Origin: repo})
}
}
@ -442,7 +474,13 @@ func getBitbucket(conf *Conf) []Repo {
if err != nil {
log.Panic().Str("stage", "bitbucket").Str("url", repo.Url).Msg(err.Error())
}
exclude := GetExcludedMap(repo.Exclude)
for _, r := range repositories.Items {
if exclude[r.Name] {
continue
}
repos = append(repos, Repo{Name: r.Name, Url: r.Links["clone"].([]interface{})[0].(map[string]interface{})["href"].(string), SshUrl: r.Links["clone"].([]interface{})[1].(map[string]interface{})["href"].(string), Token: "", Defaultbranch: r.Mainbranch.Name, Origin: repo})
}
}

@ -31,13 +31,14 @@ type Source struct {
// Generell Repo
type GenRepo struct {
Token string `yaml:"token"`
User string `yaml:"user"`
SSH bool `yaml:"ssh"`
SSHKey string `yaml:"sshkey"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Url string `yaml:"url"`
Token string `yaml:"token"`
User string `yaml:"user"`
SSH bool `yaml:"ssh"`
SSHKey string `yaml:"sshkey"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Url string `yaml:"url"`
Exclude []string `yaml:"exclude"`
}
// Repo