Skip to content

Commit 17f0034

Browse files
authored
Exclude WIldcard & Fix of Documentation (#31)
* Fix typo in description * Add wildcard exclusion for organisation or user * Bugfix * Described organization and user exclusion * Added owner exclusion to gitlab too * Fix README.md for owner exclusion
1 parent b3983ee commit 17f0034

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ github:
4040
# (default: https://api.github.com)
4141
url: https://github.mydomain.com
4242
# (optional) Exclude this list of repos
43-
excluded:
43+
# or whole organizations/users
44+
exclude:
45+
- my-excluded-org
46+
- my-excluded-user
4447
- my-namespace/excluded-repository-name
4548
# The gitlab section contains backup jobs for
4649
# GitLab.com and GitLab on premise
@@ -68,7 +71,10 @@ gitlab:
6871
# (default: https://gitlab.com/)
6972
url: https://gitlab.mydomain.com
7073
# (optional) Exclude this list of repos
71-
excluded:
74+
# or whole organizations/users
75+
exclude:
76+
- my-excluded-org
77+
- my-excluded-user
7278
- my-namespace/excluded-repository-name
7379
```
7480

github.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,18 @@ func (c *GithubConfig) ListRepositories() ([]*Repository, error) {
5151
gitUrl.User = url.UserPassword("github", c.AccessToken)
5252

5353
isExcluded := slices.ContainsFunc(c.Exclude, func(s string) bool {
54-
return strings.EqualFold(s, *repo.FullName)
54+
if strings.EqualFold(s, *repo.FullName) {
55+
return true
56+
}
57+
58+
if strings.Contains(s, "/") {
59+
return false
60+
}
61+
62+
repoFullName := *repo.FullName
63+
64+
repoOwner := repoFullName[:strings.Index(repoFullName, "/")]
65+
return strings.EqualFold(s, repoOwner)
5566
})
5667
if isExcluded {
5768
log.Printf("Skipping excluded repository: %s", *repo.FullName)

gitlab.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,18 @@ func (g *GitLabConfig) ListRepositories() ([]*Repository, error) {
6969
outSlice := make([]*Repository, 0, len(out))
7070
for _, repository := range out {
7171
isExcluded := slices.ContainsFunc(g.Exclude, func(s string) bool {
72-
return strings.EqualFold(s, repository.FullName)
72+
if strings.EqualFold(s, repository.FullName) {
73+
return true
74+
}
75+
76+
if strings.Contains(s, "/") {
77+
return false
78+
}
79+
80+
repoFullName := repository.FullName
81+
82+
repoOwner := repoFullName[:strings.Index(repoFullName, "/")]
83+
return strings.EqualFold(s, repoOwner)
7384
})
7485
if isExcluded {
7586
log.Printf("Skipping excluded repository: %s", repository.FullName)

0 commit comments

Comments
 (0)