Skip to content

Commit

Permalink
implemented exclude forks (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer authored Jun 4, 2023
1 parent 2bc4aa4 commit 64a6725
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ gickup
conf.yml
.idea
dist/
.vscode
12 changes: 12 additions & 0 deletions conf.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source:
languages: # only clone repositories with the following languages
- go
- java
excludeforks: true # exclude forked repositories
gitea:
- token: some-token
# token_file: token.txt # alternatively, specify token in a file
Expand Down Expand Up @@ -67,6 +68,7 @@ source:
languages: # only clone repositories with the following languages
- go
- java
excludeforks: true # exclude forked repositories
gogs:
- token: some-token
# token_file: token.txt # alternatively, specify token in a file
Expand Down Expand Up @@ -96,6 +98,7 @@ source:
filter:
stars: 100 # only clone repos with 100 stars
lastactivity: 1y # only clone repos which had activity during the last year
excludeforks: true # exclude forked repositories
gitlab:
- token: some-token
# token_file: token.txt # alternatively, specify token in a file
Expand Down Expand Up @@ -123,6 +126,14 @@ source:
- bar1
wiki: true # includes wiki too
starred: true # includes the user's starred repositories too
filter:
stars: 100 # only clone repos with 100 stars
lastactivity: 1y # only clone repos which had activity during the last year
excludearchived: true
languages: # only clone repositories with the following languages
- go
- java
excludeforks: true # exclude forked repositories
bitbucket:
- user: some-user # the user you want to clone the repositories from.
url: http(s)://url-to-bitbucket # if empty, it uses https://bitbucket.org
Expand Down Expand Up @@ -151,6 +162,7 @@ source:
- foobar
filter:
lastactivity: 1y # only clone repos which had activity during the last year
excludeforks: true # exclude forked repositories
sourcehut:
- token: some-token
# token_file: token.txt # alternatively, specify token in a file
Expand Down
10 changes: 10 additions & 0 deletions gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
languages := types.GetMap(repo.Filter.Languages)

for _, r := range gitearepos {
if repo.Filter.ExcludeForks {
if r.Fork {
continue
}
}
if repo.Filter.ExcludeArchived {
if r.Archived {
continue
Expand Down Expand Up @@ -404,6 +409,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}
}
for _, r := range orgrepos {
if repo.Filter.ExcludeForks {
if r.Fork {
continue
}
}
if repo.Filter.ExcludeArchived {
if r.Archived {
continue
Expand Down
5 changes: 5 additions & 0 deletions github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
languages := types.GetMap(repo.Filter.Languages)

for _, r := range githubrepos {
if repo.Filter.ExcludeForks {
if *r.Fork {
continue
}
}
if repo.Filter.ExcludeArchived {
if r.Archived != nil {
if *r.Archived {
Expand Down
10 changes: 10 additions & 0 deletions gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
languages := types.GetMap(repo.Filter.Languages)

for _, r := range gitlabrepos {
if repo.Filter.ExcludeForks {
if r.ForkedFromProject != nil {
continue
}
}
if repo.Filter.ExcludeArchived {
if r.Archived {
continue
Expand Down Expand Up @@ -355,6 +360,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}
for k, gr := range gitlabgrouprepos {
for _, r := range gr {
if repo.Filter.ExcludeForks {
if r.ForkedFromProject != nil {
continue
}
}
if repo.Filter.ExcludeArchived {
if r.Archived {
continue
Expand Down
10 changes: 10 additions & 0 deletions gogs/gogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
excludeorgs := types.GetMap(repo.ExcludeOrgs)

for _, r := range gogsrepos {
if repo.Filter.ExcludeForks {
if r.Fork {
continue
}
}
if r.Stars < repo.Filter.Stars {
continue
}
Expand Down Expand Up @@ -306,6 +311,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}
}
for _, r := range orgrepos {
if repo.Filter.ExcludeForks {
if r.Fork {
continue
}
}
if r.Stars < repo.Filter.Stars {
continue
}
Expand Down
10 changes: 10 additions & 0 deletions onedev/onedev.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}

for _, r := range userrepos {
if repo.Filter.ExcludeForks {
if r.ForkedFromID != 0 {
continue
}
}
if len(repo.Include) > 0 {
if !include[r.Name] {
continue
Expand Down Expand Up @@ -178,6 +183,11 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}

for _, r := range orgrepos {
if repo.Filter.ExcludeForks {
if r.ForkedFromID != 0 {
continue
}
}
urls, err := client.GetCloneUrl(r.ID)
if err != nil {
log.Error().
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ type Filter struct {
Stars int `yaml:"stars"`
Languages []string `yaml:"languages"`
ExcludeArchived bool `yaml:"excludearchived"`
ExcludeForks bool `yaml:"excludeforks"`
}

// GetToken TODO.
Expand Down

0 comments on commit 64a6725

Please sign in to comment.