Skip to content

Conversation

@rnorth
Copy link
Collaborator

@rnorth Richard North (rnorth) commented Nov 24, 2025

Summary

Intended to make it easy to search for turbolift-raised PRs by tools that support querying by labels (e.g. Cortex).

  • add optional --no-apply-labels flag so create-prs can skip default labeling
  • pass labels list through gh pr create; export the default label constant
  • update README and tests to cover default and opt-out flows

Copilot AI review requested due to automatic review settings November 24, 2025 17:31
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 automatic labeling of turbolift-raised PRs with a "turbolift" label by default, while allowing users to opt out via a --no-apply-labels flag.

Key changes:

  • Introduced TurboliftLabel constant and Labels field in PullRequest struct
  • Added --no-apply-labels CLI flag to skip default labeling behavior
  • Updated tests to verify both default labeling and opt-out scenarios

Reviewed changes

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

Show a summary per file
File Description
internal/github/github.go Added TurboliftLabel constant, Labels field to PullRequest struct, and label application logic in CreatePullRequest
internal/github/github_test.go Updated existing test expectations to include default label; added new test for label-free PR creation
internal/github/fake_github.go Modified CreatePullRequest to capture labels in fake implementation for test verification
cmd/create_prs/create_prs.go Added --no-apply-labels flag and logic to conditionally apply default label
cmd/create_prs/create_prs_test.go Updated test expectations and added new test case for --no-apply-labels flag
README.md Documented new default labeling behavior and opt-out flag; clarified development task descriptions
AGENTS.md Added new documentation file with repository guidelines for AI agents

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

@rnorth Richard North (rnorth) marked this pull request as draft November 24, 2025 17:32
@rnorth Richard North (rnorth) marked this pull request as ready for review November 25, 2025 09:40
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

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


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

Comment on lines 94 to 105
func (r *RealGitHub) ensureLabelExists(output io.Writer, workingDir string, repo string, label string) error {
args := []string{
"label",
"create",
label,
"--repo",
repo,
"--color",
turboliftLabelColor,
"--description",
turboliftLabelDescription,
}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The color and description are hardcoded for all labels, but the function accepts any label name. This creates inconsistency when non-turbolift labels are used. Consider either: (1) making this function turbolift-specific by removing the label parameter and using TurboliftLabel constant directly, or (2) accepting color and description as parameters if generic label support is intended.

Copilot uses AI. Check for mistakes.
Comment on lines 57 to 61
if len(pr.Labels) > 0 {
for _, label := range pr.Labels {
if err := r.ensureLabelExists(output, workingDir, pr.UpstreamRepo, label); err != nil {
return false, err
}
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

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

The outer if len(pr.Labels) > 0 check is unnecessary. The for-range loop over pr.Labels already handles empty slices gracefully by not iterating. This check can be removed to simplify the code.

Suggested change
if len(pr.Labels) > 0 {
for _, label := range pr.Labels {
if err := r.ensureLabelExists(output, workingDir, pr.UpstreamRepo, label); err != nil {
return false, err
}
for _, label := range pr.Labels {
if err := r.ensureLabelExists(output, workingDir, pr.UpstreamRepo, label); err != nil {
return false, err

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

good copilot


"github.com/skyscanner/turbolift/internal/executor"
)

Choose a reason for hiding this comment

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

funny, github doesn't show any syntax highlighting on this one?

"--repo",
repo,
"--color",
turboliftLabelColor,

Choose a reason for hiding this comment

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

I wonder if we should set the colour here - is this a mandator option when creating the label?

- Remove unnecessary len check before iteration (for-range handles empty slices)
- Rename ensureLabelExists to ensureTurboliftLabelExists and make it turbolift-specific
- Use TurboliftLabel constant directly instead of passing as parameter
- Keep fixed color (0366d6 - blue) for turbolift labels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
The Labels field was only ever set to []string{TurboliftLabel} or nil,
effectively acting as a boolean flag. This refactor:

- Replaces Labels []string with ApplyLabels bool in PullRequest struct
- Simplifies CreatePullRequest logic - no more iteration over labels
- Makes intent clearer in create_prs.go: ApplyLabels: !noApplyLabels
- Updates fake implementation to use boolean check
- Updates all tests to use the new boolean field

This eliminates unnecessary complexity and makes the code more maintainable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
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