fix(changelog): strip newline from git describe output

What does this MR do and why?

Fixes glab changelog generate when invoked without --version.

DescribeByTags returned the output of git describe --tags verbatim, including the trailing newline that git always emits. The newline was URL-encoded as %0A in the API query string, and GitLab rejected the request with:

422 Unprocessable Entity
{"message":"Failed to generate the changelog: The requested `version` attribute format is not correct. Use formats such as `1.0.0` or `v1.0.0`."}

Fix

  1. Use the existing firstLine helper in DescribeByTags. This helper is already the local idiom for single-line git command output — ToplevelDir and GitDir both use it for the same reason.
  2. Update TestDescribeByTags expected values back to what they were when the test was originally introduced (in 2023 with feat: add new changelog command, commit 4f200f91). Those expectations were changed to accept the buggy "1.0.0\n" output in April 2024 (commit 1fa0f55d, test: have git tests actually use git instead of stubs) when the test switched from stubs to a real git repo — instead of fixing the underlying bug, the expectations were adjusted to match observed behavior. This MR restores the original, correct expectations.

How to reproduce (before the fix)

  1. Create a repository, add an initial commit, tag it v0.0.0.
  2. Add commits with Changelog: trailers.
  3. glab changelog generate (no --version) → 422.

With --version=$(git describe --tags) the shell strips the trailing newline, which is why the failure was invisible with --version.

Merge request reports

Loading