Skip to content

Conversation

@ipmb
Copy link
Member

@ipmb ipmb commented Nov 9, 2025

No description provided.

ipmb added 2 commits November 9, 2025 13:33
Add optional --ref flag to `build start` command to allow building from
specific git references (branches, tags, or commit hashes).

Changes:
- Add --ref flag to buildStartCmd (cmd/build.go)
- Update StartBuild() signature to accept ref parameter (app/app.go)
- Extract DetermineBuildSourceVersion() helper function for testability
  (app/builds.go)
- Add comprehensive unit tests for DetermineBuildSourceVersion()
  (app/builds_test.go) with 100% coverage
- Update reviewapps.go to pass empty ref to StartBuild()

The --ref flag accepts any git reference that CodeBuild supports:
- Branch names: --ref develop
- Tags: --ref v1.2.3
- Commit hashes: --ref abc123def456

When no --ref is provided, CodeBuild uses the default branch configured
in the project. Review apps continue to use the pr/{number} format and
take precedence over the --ref flag.

The core logic is extracted into DetermineBuildSourceVersion(), a pure
function that determines the appropriate SourceVersion parameter based
on whether the app is a review app and if a custom ref is provided.
This design makes the logic easy to test without mocking AWS services.
@ipmb ipmb requested a review from Copilot November 9, 2025 19:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for building from custom git references by introducing a --ref flag to the build start command. The implementation extracts build source version determination logic into a testable helper function.

  • Added --ref flag to allow building from specific branches, tags, or commit hashes
  • Refactored build source version logic into DetermineBuildSourceVersion function with comprehensive test coverage
  • Updated StartBuild method signature to accept the ref parameter

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
CHANGELOG.md Documents the new --ref flag feature and Go version update
app/builds.go Introduces DetermineBuildSourceVersion helper function to centralize source version logic
app/builds_test.go Adds comprehensive test coverage for the new helper function
app/app.go Refactors StartBuild to use the new helper function and accept ref parameter
cmd/build.go Adds --ref flag declaration and passes it to StartBuild
cmd/reviewapps.go Updates StartBuild call to pass empty string for ref parameter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ipmb ipmb merged commit 724cb09 into main Nov 10, 2025
10 checks passed
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.

2 participants