Skip to content

feat(internal/cli): add version command#2894

Merged
JoeWang1127 merged 7 commits intomainfrom
feat/add-version-cmd
Nov 13, 2025
Merged

feat(internal/cli): add version command#2894
JoeWang1127 merged 7 commits intomainfrom
feat/add-version-cmd

Conversation

@JoeWang1127
Copy link
Copy Markdown
Contributor

@JoeWang1127 JoeWang1127 commented Nov 13, 2025

Refactor command initialization, make version command as a default command in each command set.

For #2416

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 92.59259% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (000d3a0) to head (ac60553).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/cli/cli.go 84.61% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2894      +/-   ##
==========================================
+ Coverage   83.02%   83.32%   +0.30%     
==========================================
  Files         132      132              
  Lines       10890    10902      +12     
==========================================
+ Hits         9041     9084      +43     
+ Misses       1440     1406      -34     
- Partials      409      412       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoeWang1127
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a version command to the automation package. The implementation is correct and follows the existing command structure. I have one suggestion to improve the newly added test to make it more robust by verifying the command's output.

@JoeWang1127 JoeWang1127 marked this pull request as ready for review November 13, 2025 16:18
@JoeWang1127 JoeWang1127 requested a review from a team as a code owner November 13, 2025 16:18
@ldetmer
Copy link
Copy Markdown
Contributor

ldetmer commented Nov 13, 2025

This is a brand new command correct? Why do we need to add it?

@julieqiu
Copy link
Copy Markdown
Member

I would move this to internal/cli so it gets added to every command, since this is exactly the same as librarian version by default:

func (c *Command) Init() *Command {

@JoeWang1127 JoeWang1127 changed the title feat(internal/automation): add version cmd chore(internal/cli): refactor command initialization Nov 13, 2025
@JoeWang1127
Copy link
Copy Markdown
Contributor Author

This is a brand new command correct? Why do we need to add it?

A version command is useful in a command line tool, we can use it to test the command is installed correctly, or trace back to the revision of the source code when debugging issues.

@JoeWang1127
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the command initialization logic by introducing a NewCommandSet helper function. This is a positive change that centralizes command set creation and automatically includes a version command, improving consistency and reducing boilerplate code. The refactoring is correctly applied to both the automation and librarian command structures. My review includes feedback on a potential side effect in the new helper function where it modifies its input slice, and a suggestion to enhance the newly added test for better coverage and specificity.

@julieqiu
Copy link
Copy Markdown
Member

Refactor command initialization, make version command as a default command in each command set.

For #2416

For clarity, I would make the PR title:

feat(internal/cli): add version command

@JoeWang1127 JoeWang1127 changed the title chore(internal/cli): refactor command initialization feat(internal/cli): add version command Nov 13, 2025
@JoeWang1127 JoeWang1127 merged commit 8f85be0 into main Nov 13, 2025
11 checks passed
@JoeWang1127 JoeWang1127 deleted the feat/add-version-cmd branch November 13, 2025 20:13
ldetmer added a commit that referenced this pull request Nov 20, 2025
PR created by the Librarian CLI to initialize a release. Merging this PR
will auto trigger a release.

Librarian Version: not available
Language Image:
us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-release-container:latest
<details><summary>librarian: 0.7.0</summary>

##
[0.7.0](v0.6.0...v0.7.0)
(2025-11-20)

### Features

* add command execution package with logging (#2968)
([12f4e94](12f4e949))

* add branch support to RepositoryConfig (#2906)
([2cab5d6](2cab5d65))

* add image sha as a config in repositories config (#2954)
([3d1f537](3d1f5375))

* add initial config (#2965)
([502b063](502b063c))

* add fetch package (#2964)
([53de44d](53de44d8))

* parse gapic_metadata for API version release notes (#2815)
([7ee0328](7ee03283))

* onboard 25 repositories to automation for publish-release (#2907)
([87fae04](87fae04a))

* add version command (#2894)
([8f85be0](8f85be09))

* add RequireCommand test helper (#2978)
([a820a71](a820a710))

* add initial command (#2961)
([c959aea](c959aeae))

* add `stage-release` command (#2902)
([ee05006](ee050065))

### Bug Fixes

* require git v2.28.0 (#2963)
([265ee47](265ee47f))

* enums referenced outside the package (#2952)
([7331816](73318169))

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants