From 3952baeb2d8667a73c23db49deaf165021f2f201 Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 14:30:57 +0100 Subject: [PATCH 1/6] Fix typo in description --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a3b6cb..45b4916 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ github: # (default: https://api.github.com) url: https://github.mydomain.com # (optional) Exclude this list of repos - excluded: + exclude: - my-namespace/excluded-repository-name # The gitlab section contains backup jobs for # GitLab.com and GitLab on premise @@ -68,7 +68,7 @@ gitlab: # (default: https://gitlab.com/) url: https://gitlab.mydomain.com # (optional) Exclude this list of repos - excluded: + exclude: - my-namespace/excluded-repository-name ``` From e9cc178841018c152aa65794cd525f646f1a424c Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 14:31:36 +0100 Subject: [PATCH 2/6] Add wildcard exclusion for organisation or user --- github.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/github.go b/github.go index 80bc9d0..962b562 100644 --- a/github.go +++ b/github.go @@ -51,7 +51,16 @@ 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 + } + + repoOwner = *repo.FullName[:strings.Index(*repo.FullName, "/")] + return strings.EqualFold(s, repoOwner) }) if isExcluded { log.Printf("Skipping excluded repository: %s", *repo.FullName) From 20ed6ab4e5f73e4c5603269e97968fd7e32e4b1a Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 14:38:17 +0100 Subject: [PATCH 3/6] Bugfix --- github.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github.go b/github.go index 962b562..915acdd 100644 --- a/github.go +++ b/github.go @@ -59,7 +59,9 @@ func (c *GithubConfig) ListRepositories() ([]*Repository, error) { return false } - repoOwner = *repo.FullName[:strings.Index(*repo.FullName, "/")] + repoFullName := *repo.FullName + + repoOwner := repoFullName[:strings.Index(repoFullName, "/")] return strings.EqualFold(s, repoOwner) }) if isExcluded { From 4775f6c3019b66c237118acc64786fd0ba18fffe Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 14:55:16 +0100 Subject: [PATCH 4/6] Described organization and user exclusion --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 45b4916..4e06533 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,10 @@ gitlab: # (default: https://gitlab.com/) url: https://gitlab.mydomain.com # (optional) Exclude this list of repos + # or whole organizations/users exclude: + - my-excluded-org + - my-excluded-user - my-namespace/excluded-repository-name ``` From bb007daf3bf2f8f92524cfb47765412dc9ab6bc3 Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 15:00:49 +0100 Subject: [PATCH 5/6] Added owner exclusion to gitlab too --- gitlab.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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) From 7121b243cf6a3daea324da01ecf7dad8edffe6cf Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Sun, 19 Jan 2025 15:01:18 +0100 Subject: [PATCH 6/6] Fix README.md for owner exclusion --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 4e06533..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 + # 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