Skip to content

Commit

Permalink
Merge pull request #336 from gravitational/paul.gottschling/2025-02-2…
Browse files Browse the repository at this point in the history
…5-docpaths

[bot] Ignore includes in docpaths
  • Loading branch information
fheinecke authored Feb 25, 2025
2 parents 06995f2 + d797f46 commit 0134753
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bot/internal/bot/docpaths.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ func toURLPath(p string) string {
return redir + "/"
}

// includeSegment is a file path segment that indicates the presence of
// includes, which we don't check for redirects if a PR renames or deletes them.
// Since PR filenames come from the GitHub API, paths include forward slashes.
const includeSegment = "/includes/"

// missingRedirectSources checks renamed or deleted docs pages in files to
// ensure that there is a corresponding redirect source in conf. For any missing
// redirects, it lists redirect sources that should be in conf.
Expand All @@ -112,6 +117,11 @@ func missingRedirectSources(conf []DocsRedirect, files github.PullRequestFiles)
continue
}

// Skip partials
if strings.Contains(f.Name, includeSegment) {
continue
}

switch f.Status {
case "renamed":
p := toURLPath(f.PreviousName)
Expand Down
28 changes: 28 additions & 0 deletions bot/internal/bot/docpaths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,34 @@ func TestMissingRedirectSources(t *testing.T) {
},
expected: []string{},
},
{
description: "renamed 3rd-level includes path with no redirects",
files: github.PullRequestFiles{
{
Name: "docs/pages/includes/databases/mysql-certs.mdx",
Additions: 0,
Deletions: 0,
Status: "renamed",
PreviousName: "docs/pages/includes/databases/mysql.mdx",
},
},
redirects: []DocsRedirect{},
expected: []string{},
},
{
description: "renamed 4rd-level includes path with no redirects",
files: github.PullRequestFiles{
{
Name: "docs/pages/connect-your-client/includes/mysql-certs.mdx",
Additions: 0,
Deletions: 0,
Status: "renamed",
PreviousName: "docs/pages/connect-your-client/includes/mysql.mdx",
},
},
redirects: []DocsRedirect{},
expected: []string{},
},
}

for _, c := range cases {
Expand Down

0 comments on commit 0134753

Please sign in to comment.