Skip to content

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Jan 15, 2026

Impetus

The --use-pr-number option is no longer working. The filename output from "docs-builder changelog add" is unchanged when that option is present.

Problem

Before this PR, the following command (with the config file from elastic/elasticsearch#140141):

./docs-builder changelog add --prs 140034 \
  --repo elasticsearch --owner elastic \
  --products "elasticsearch 9.3.0" \
  --output /GitHub/elasticsearch/docs/changelog/ \
  --type bug-fix --config /GitHub/elasticsearch/docs/changelog.yml --use-pr-number

... incorrectly generated a file called 1768517811-esql-fix-extent-reading-when-missing.yaml.
This is a regression from the behaviour implemented in #2422.

With this PR fix, it once again generates a file called 140034.yaml.

Solution

The --use-pr-number option wasn't working because:

  1. Filename generation ignored UsePrNumber: In CreateSingleChangelog (lines 388-393), the code always generated timestamp-based filenames ({timestamp}-{slug}.yaml) without checking input.UsePrNumber.

  2. Missing property copy for multiple PRs: In CreateChangelogsForMultiplePrs (lines 131-149), when creating a copy of the input for each PR, the UsePrNumber property wasn't being copied, so it was lost when processing multiple PRs.

Fixes Applied

  1. Updated filename generation (lines 381-410): Added logic to check input.UsePrNumber. When true and a PR URL is provided, it extracts the PR number using the existing ExtractPrNumber method and uses {prNumber}.yaml as the filename. Falls back to the timestamp-based format if extraction fails.

  2. Fixed property copy (line 148): Added UsePrNumber = input.UsePrNumber to the prInput copy in CreateChangelogsForMultiplePrs so the flag is preserved when processing multiple PRs.

The build completed successfully with no errors. Your command should now create a file named 140034.yaml instead of the timestamp-based filename.

Testing

  • Added a test CreateChangelog_WithUsePrNumber_CreatesFileWithPrNumberAsFilename in tests/Elastic.Documentation.Services.Tests/ChangelogServiceTests.cs to verify that when --use-pr-number is used, the changelog filename is the PR number (e.g., 140034.yaml) instead of a timestamp-based name.

The test:

  1. Sets up a mock GitHub PR service that returns PR info for PR #140034
  2. Creates a ChangelogInput with UsePrNumber = true and a PR URL
  3. Calls CreateChangelog to generate the changelog file
  4. Asserts that exactly one file is created
  5. Verifies the filename is 140034.yaml (not a timestamp-based name like 1768517811-esql-fix-extent-reading-when-missing.yaml)
  6. Verifies the YAML content is correct

The test:

  • Compiles successfully
  • Passes when executed
  • Has no linter errors
  • Follows the existing test patterns in the file

This ensures the --use-pr-number option works as expected and prevents regressions.

Generative AI disclosure

  1. Did you use a generative AI (GenAI) tool to assist in creating this contribution?
  • Yes
  • No
  1. If you answered "Yes" to the previous question, please specify the tool(s) and model(s) used (e.g., Google Gemini, OpenAI ChatGPT-4, etc.).

Tool(s) and model(s) used: composer-1

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
…null'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants