Skip to content

feat(internal/automation): add branch support to RepositoryConfig#2906

Merged
noahdietz merged 5 commits intogoogleapis:mainfrom
noahdietz:librarian-repository-branch
Nov 17, 2025
Merged

feat(internal/automation): add branch support to RepositoryConfig#2906
noahdietz merged 5 commits intogoogleapis:mainfrom
noahdietz:librarian-repository-branch

Conversation

@noahdietz
Copy link
Copy Markdown
Contributor

@noahdietz noahdietz commented Nov 13, 2025

Adds Branch property to the RepositoryConfig. This property configures the repository branch to be checked out by Cloud Build and the value of the --branch flag passed to each librarian command (as described in #2763 (comment)).

The Cloud Build job is informed via the _BRANCH substitution which will only be set here when RepositoryConfig.Branch is set.

The test cases for TestRunCommandWithConfig are expanded to cover other triggers and to include expected substitutions for each.

Note: As mentioned in #2763 (comment), I'm not sure how the _BRANCH substitution is currently defaulted (if at all) for the clone-language-repo step that uses git clone --branch (which should error out if provided with an empty value). All of the librarian commands default to main when --branch is empty/unset.

Fixes #2763

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.32%. Comparing base (ee05006) to head (01e83e8).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2906   +/-   ##
=======================================
  Coverage   83.32%   83.32%           
=======================================
  Files         133      133           
  Lines       10926    10928    +2     
=======================================
+ Hits         9104     9106    +2     
  Misses       1409     1409           
  Partials      413      413           

☔ 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.

@noahdietz noahdietz marked this pull request as ready for review November 14, 2025 17:27
@noahdietz noahdietz requested a review from a team as a code owner November 14, 2025 17:27
@ldetmer
Copy link
Copy Markdown
Contributor

ldetmer commented Nov 14, 2025

/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 introduces support for specifying a branch in the RepositoryConfig, which is then used to set the _BRANCH substitution for Cloud Build triggers. The implementation is correct and well-tested for the new functionality. My review includes suggestions to improve the test mock (mockCloudBuildClient) to better handle scenarios involving multiple repositories. Specifically, I've recommended changes to allow the mock to record all trigger runs and their substitutions, which will enhance the overall quality and reliability of the tests.

@noahdietz
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 introduces a Branch property to the RepositoryConfig to allow specifying a branch for Cloud Build jobs. The implementation correctly passes this branch as a _BRANCH substitution. The changes are well-tested, with new unit tests verifying the configuration parsing and the substitution logic. Overall, this is a solid contribution that enhances the automation capabilities. I have one minor suggestion to improve the readability of the test code.

@noahdietz
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 support for specifying a branch in the RepositoryConfig. The change is well-implemented, adding the Branch field to the configuration, using it to set the _BRANCH substitution for Cloud Build, and including tests to verify the new functionality. The related test mocks and test cases have been updated accordingly. I have one suggestion to improve the test suite's consistency and robustness, which I've added as a comment.

@noahdietz
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 support for specifying a branch in the repository configuration, which is then passed as a substitution to Cloud Build triggers. The implementation is straightforward and the new functionality is well-tested. I've also noticed that you've improved the existing tests by adding missing fields and assertions for substitutions, which is great. I have one suggestion to improve the maintainability of the newly added tests.

@noahdietz noahdietz merged commit 2cab5d6 into googleapis:main Nov 17, 2025
6 checks passed
@noahdietz noahdietz deleted the librarian-repository-branch branch November 17, 2025 17:24
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.

automation: add branch property to repository configuration

2 participants