Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase the last one in branch chain to make update-refs great again #152

Open
vasilich6107 opened this issue Oct 29, 2024 · 1 comment
Open

Comments

@vasilich6107
Copy link

vasilich6107 commented Oct 29, 2024

Hi.

Sometimes there is a need to create a chain of branches like

  • branch1
  • branch2 from branch1
  • branch3 from branch2
  • branch4 from branch3

While rebasing branch1 all other branches will be full of conflicts due to obvious reason.

There is an --update-refs flag for git which works only if the branch being rebased is the last one.

So having some boolean flag like rebase-last(just an example) in conjunction with rebase-options: --update-refs could be a game changer.

To get last branch of the chain there is

git branch --contains branch1 | tail -n 1
@vasilich6107
Copy link
Author

vasilich6107 commented Oct 29, 2024

@peter-evans
I have some pseudo code, it would be nice if you could check.

Technically if the flag is true we could hook somewhere before here
https://github.com/peter-evans/rebase/blob/main/dist/index.js#L640

let headRef = pull.headRef;
if(flag_is_true) {
  core.startGroup(`Resolving the bottom most branch chained from '${headRef}'.`);
  headRef = yield this.git.exec(['branch', `--contains`, headRef, '|', 'tail', '-n', '1']);
  core.info(`Resolved ref is '${headRef}'.`);
  core.endGroup();
}

in order to replace the closest to main - branch1 to the furthest from main - branch4

and then code continues as previously

// Fetch
core.startGroup(`Fetching head ref '${headRef}'.`);
yield this.git.fetch([headRef], remoteName);

does it make sense for you?

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

No branches or pull requests

1 participant