Skip to content

fix: create new downstream branches from last minor release instead of next - #955

Open
divyansh42 wants to merge 2 commits into
mainfrom
fix/branch-from-last-minor-release
Open

divyansh42 wants to merge 2 commits into
mainfrom
fix/branch-from-last-minor-release

Conversation

@divyansh42

Copy link
Copy Markdown
Collaborator

Summary

  • When a target branch does not exist in a downstream repo, it was previously created from origin/next (fallback: origin/main), causing new release branches to inherit unreleased content
  • Now uses previousReleaseBranch() to find the highest release-vX.Y.x branch strictly older than the target and sources the new branch from there
  • Fails hard if no previous release branch exists — no silent fallback

Test plan

  • Trigger generate-konflux for a new release version where the downstream branch does not yet exist
  • Verify the new branch is created from the previous minor release (e.g., release-v1.16.x sources from release-v1.15.x)
  • Verify the operation fails with a clear error if no older release branch exists on the remote

🤖 Generated with Claude Code

@divyansh42

Copy link
Copy Markdown
Collaborator Author

Need to test this manually.

@divyansh42

Copy link
Copy Markdown
Collaborator Author

/hold

@divyansh42

Copy link
Copy Markdown
Collaborator Author

Need to test this manually.

I have test it and it is working fine.
@pramodbindal can you please review

Comment thread internal/konflux/git.go
Comment thread internal/konflux/git.go Outdated
Comment thread internal/konflux/git.go Outdated
Comment thread internal/konflux/git.go Outdated
…f next

When a target branch does not exist in a downstream repo, it was previously
created from origin/next. New release branches now source from the immediate
predecessor release-vX.(Y-1).x instead.

If no release branches exist on the remote at all, the component is treated
as newly onboarded and next is used as the source. Any other missing
predecessor is a hard failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@divyansh42
divyansh42 force-pushed the fix/branch-from-last-minor-release branch from a1fb035 to 0e015c5 Compare September 15, 2026 07:04
@divyansh42

Copy link
Copy Markdown
Collaborator Author

@pramodbindal I have resolved the comment, can you please check now?

Comment thread internal/konflux/git.go
// Previous release branch not found. Check whether any release branches
// exist on the remote. If none do, this is a new component being onboarded
// and we fall back to next as the source.
out, err = run(ctx, dir, "git", "ls-remote", "--heads", "origin", "release-v*.x")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

git ls-remote --heads origin release-v*.x
when i run this command on a repo i get " no matches found: release-v*.x"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@pramodbindal could you. please try as:

> git ls-remote --heads upstream 'release-v*.x'
0c08df6897356ae4aedfaf2914711fa742378146	        refs/heads/release-v0.50.x
486a77680dc9b5b0b7d11e697ac72e51ed80c029	refs/heads/release-v0.51.x
86c7ea53e17200b9ae6fc6ec708aacf96533660b	refs/heads/release-v0.52.x

run() uses exec.Command directly, so the argument is passed to git as a literal string
quoting the pattern ('release-v*.x') fixes it in the shell

Comment thread internal/konflux/git.go
minor, _ := strconv.Atoi(m[2])

prev := fmt.Sprintf("release-v%d.%d.x", major, minor-1)
out, err := run(ctx, dir, "git", "ls-remote", "--heads", "origin", prev)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will work until major version does not change.
when major version changes then minor becomes 0 and prev becomes -1
i would suggest to handle that case as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@pramodbindal in the case shall I throw the error? as few other changes might also be required? or should i create the branch for last minor release. i.e major-1.Y.x
Y will be the last minor release of the previous version.

@pramodbindal

Copy link
Copy Markdown
Member

Please Add the documentation as well.

A Readme update should be fine

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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