mirror of
https://github.com/cooperspencer/gickup
synced 2025-04-30 18:27:56 +02:00
Merge pull request #15 from cooperspencer/exclude-list
added function to exclude repos
This commit is contained in:
commit
de73a85b32
19
.github/workflows/go.yml
vendored
19
.github/workflows/go.yml
vendored
@ -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
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
bla.conf
|
||||
gickup
|
||||
gickup
|
||||
conf.yml
|
15
README.md
15
README.md
@ -23,6 +23,9 @@ source:
|
||||
password: bla
|
||||
ssh: true # can be true or false
|
||||
sshkey: /path/to/key # if empty, it uses your home directories' .ssh/id_rsa
|
||||
exclude: # this excludes the repos foo and bar
|
||||
- foo
|
||||
- bar
|
||||
gitea:
|
||||
- token: blabla
|
||||
user: blabla
|
||||
@ -31,6 +34,9 @@ source:
|
||||
password: bla
|
||||
ssh: true # can be true or false
|
||||
sshkey: /path/to/key # if empty, it uses your home directories' .ssh/id_rsa
|
||||
exclude: # this excludes the repos foo and bar
|
||||
- foo
|
||||
- bar
|
||||
gogs:
|
||||
- token: blabla
|
||||
user: blabla
|
||||
@ -39,6 +45,9 @@ source:
|
||||
password: bla
|
||||
ssh: true # can be true or false
|
||||
sshkey: /path/to/key # if empty, it uses your home directories' .ssh/id_rsa
|
||||
exclude: # this excludes the repos foo and bar
|
||||
- foo
|
||||
- bar
|
||||
gitlab:
|
||||
- token: blabla
|
||||
user: blabla
|
||||
@ -47,6 +56,9 @@ source:
|
||||
password: bla
|
||||
ssh: true # can be true or false
|
||||
sshkey: /path/to/key # if empty, it uses your home directories' .ssh/id_rsa
|
||||
exclude: # this excludes the repos foo and bar
|
||||
- foo
|
||||
- bar
|
||||
bitbucket:
|
||||
- user: blabla
|
||||
url: blabla
|
||||
@ -54,6 +66,9 @@ source:
|
||||
password: blabla
|
||||
ssh: true # can be true or false
|
||||
sshkey: /path/to/key # if empty, it uses your home directories' .ssh/id_rsa
|
||||
exclude: # this excludes the repos foo and bar
|
||||
- foo
|
||||
- bar
|
||||
destination:
|
||||
gitea:
|
||||
- token: blabla
|
||||
|
38
main.go
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})
|
||||
}
|
||||
}
|
||||
|
15
types.go
15
types.go
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user