Skip to content

Move head branch of empty rebase PRs #5656

@premun

Description

@premun

Problem

We have the following situation:

  1. We have some commits on the target branch:

    gitGraph
        commit
        commit
        commit
    
    Loading
  2. We create a codeflow PR that has a conflict, so it only creates the "initializer" empty commit, like so:

    gitGraph
        commit
        commit id: "PR base commit"
        branch prBranch
        commit id: "Initial PR commit"
        checkout main
        commit
    
    Loading
  3. Now no one tends to the PR and more commits merge into the target branch

    gitGraph
        commit
        commit id: "PR base commit"
        branch prBranch
        commit id: "Initial PR commit"
        checkout main
        commit
        commit id: "new commit #1"
        commit id: "new commit #2"
        commit id: "new commit #3"
    
    Loading
  4. Now if the service wants to flow new commits, the PR branch already exists and can't be rebased properly.

Goal

When no commits were flown yet, we should instead recreate the PR branch like it would be at the top of the main branch.

gitGraph
    commit
    commit
    commit
    commit id: "new commit #1"
    commit id: "new commit #2"
    commit id: "new commit #3"
    branch prBranch
    commit id: "Initial PR commit"
Loading

But, we can't do it during the flow because then the dev would need to force-push.
Instead, I think whenever the service flows new build, it should check if it actually made any commits so far and if not, it should rebase+force-push.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions