diff --git a/README.md b/README.md index 7a3b6cb..7c0f5c9 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,10 @@ github: # (default: https://api.github.com) url: https://github.mydomain.com # (optional) Exclude this list of repos - excluded: + # or whole organizations/users + exclude: + - my-excluded-org + - my-excluded-user - my-namespace/excluded-repository-name # The gitlab section contains backup jobs for # GitLab.com and GitLab on premise @@ -68,7 +71,10 @@ gitlab: # (default: https://gitlab.com/) url: https://gitlab.mydomain.com # (optional) Exclude this list of repos - excluded: + # or whole organizations/users + exclude: + - my-excluded-org + - my-excluded-user - my-namespace/excluded-repository-name ``` diff --git a/github.go b/github.go index 80bc9d0..915acdd 100644 --- a/github.go +++ b/github.go @@ -51,7 +51,18 @@ func (c *GithubConfig) ListRepositories() ([]*Repository, error) { gitUrl.User = url.UserPassword("github", c.AccessToken) isExcluded := slices.ContainsFunc(c.Exclude, func(s string) bool { - return strings.EqualFold(s, *repo.FullName) + if strings.EqualFold(s, *repo.FullName) { + return true + } + + if strings.Contains(s, "/") { + return false + } + + repoFullName := *repo.FullName + + repoOwner := repoFullName[:strings.Index(repoFullName, "/")] + return strings.EqualFold(s, repoOwner) }) if isExcluded { log.Printf("Skipping excluded repository: %s", *repo.FullName) diff --git a/gitlab.go b/gitlab.go index 6c8d74f..c22ab36 100644 --- a/gitlab.go +++ b/gitlab.go @@ -69,7 +69,18 @@ func (g *GitLabConfig) ListRepositories() ([]*Repository, error) { outSlice := make([]*Repository, 0, len(out)) for _, repository := range out { isExcluded := slices.ContainsFunc(g.Exclude, func(s string) bool { - return strings.EqualFold(s, repository.FullName) + if strings.EqualFold(s, repository.FullName) { + return true + } + + if strings.Contains(s, "/") { + return false + } + + repoFullName := repository.FullName + + repoOwner := repoFullName[:strings.Index(repoFullName, "/")] + return strings.EqualFold(s, repoOwner) }) if isExcluded { log.Printf("Skipping excluded repository: %s", repository.FullName)