diff --git a/bot/internal/bot/docpaths.go b/bot/internal/bot/docpaths.go index 924e48f..6fc6fe3 100644 --- a/bot/internal/bot/docpaths.go +++ b/bot/internal/bot/docpaths.go @@ -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. @@ -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) diff --git a/bot/internal/bot/docpaths_test.go b/bot/internal/bot/docpaths_test.go index 1aba114..e3efbea 100644 --- a/bot/internal/bot/docpaths_test.go +++ b/bot/internal/bot/docpaths_test.go @@ -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 {