From aa4a2f2c9f42d68b057374019781964e6b091896 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 17 Jan 2025 11:03:03 -0800 Subject: [PATCH 1/3] [chore][githubgen] Fix code owner whitespace issues --- githubgen/codeowners.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/githubgen/codeowners.go b/githubgen/codeowners.go index f15b2b61..c7847c15 100644 --- a/githubgen/codeowners.go +++ b/githubgen/codeowners.go @@ -178,7 +178,13 @@ LOOP: for _, m := range dist.Maintainers { maintainers = append(maintainers, fmt.Sprintf("@%s", m)) } - codeowners += fmt.Sprintf("reports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers %s\n", dist.Name, strings.Repeat(" ", longestName-len(dist.Name)), strings.Join(maintainers, " ")) + + distribution := fmt.Sprintf("reports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers", dist.Name, strings.Repeat(" ", longestName-len(dist.Name))) + if len(maintainers) > 0 { + distribution += fmt.Sprintf(" %s", strings.Join(maintainers, " ")) + } + + codeowners += fmt.Sprintf("%s\n", distribution) } err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0o600) From 480d6cd13e0914b2885e26e36e345858cfe00e1e Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 17 Jan 2025 11:16:08 -0800 Subject: [PATCH 2/3] Move around newline formatting --- githubgen/codeowners.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/githubgen/codeowners.go b/githubgen/codeowners.go index c7847c15..c05bf599 100644 --- a/githubgen/codeowners.go +++ b/githubgen/codeowners.go @@ -179,12 +179,12 @@ LOOP: maintainers = append(maintainers, fmt.Sprintf("@%s", m)) } - distribution := fmt.Sprintf("reports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers", dist.Name, strings.Repeat(" ", longestName-len(dist.Name))) + distribution := fmt.Sprintf("\nreports/distributions/%s.yaml%s @open-telemetry/collector-contrib-approvers", dist.Name, strings.Repeat(" ", longestName-len(dist.Name))) if len(maintainers) > 0 { distribution += fmt.Sprintf(" %s", strings.Join(maintainers, " ")) } - codeowners += fmt.Sprintf("%s\n", distribution) + codeowners += fmt.Sprintf("%s", distribution) } err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0o600) From 42a3e0d9995f1ca06bdaa1164f6e1a525ff6a5a7 Mon Sep 17 00:00:00 2001 From: Curtis Robert Date: Fri, 17 Jan 2025 11:23:58 -0800 Subject: [PATCH 3/3] Simplify logic --- githubgen/codeowners.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/githubgen/codeowners.go b/githubgen/codeowners.go index c05bf599..95d26fe9 100644 --- a/githubgen/codeowners.go +++ b/githubgen/codeowners.go @@ -184,7 +184,7 @@ LOOP: distribution += fmt.Sprintf(" %s", strings.Join(maintainers, " ")) } - codeowners += fmt.Sprintf("%s", distribution) + codeowners += distribution } err = os.WriteFile(filepath.Join(".github", "CODEOWNERS"), []byte(codeowners+unmaintainedCodeowners), 0o600)