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
- Use the existing
firstLinehelper inDescribeByTags. This helper is already the local idiom for single-linegitcommand output —ToplevelDirandGitDirboth use it for the same reason. - Update
TestDescribeByTagsexpected values back to what they were when the test was originally introduced (in 2023 withfeat: 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)
- Create a repository, add an initial commit, tag it
v0.0.0. - Add commits with
Changelog:trailers. 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.