saitho / semantic-release-backmerge

:twisted_rightwards_arrows: semantic-release plugin to back-merge a release into a develop branch
https://saitho.github.io/semantic-release-backmerge/
56 stars 11 forks source link

Rebase hotfixes #35

Open ciltocruz opened 2 years ago

ciltocruz commented 2 years ago

Hello.

I have a problem and I want to ask if there is any way to solve it. It is not a bug of the plugin. it works quite well, but I have found a casuistry in which it has caused an error. I don't know if I haven't configured it correctly.

I've made a feature (feat 1) and merged it into my develop branch. This feature is in the testing phase. Suddenly a hotfix appears in production (main).

The hotfix is pushed to main directly (hotfix/someName --> main).

When doing "rebase" from main to develop, the problem appears indicating that there are previous commits (feat 1) and that I must pull.

[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Performing back-merge into develop branch "develop".
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Branch is detached. Checking out release branch "main".
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Checking out develop branch "develop".
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Performing backmerge with "rebase" strategy.
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Loading plugins
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Executing "done" step of plugins
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Found 0 staged files for back-merge commit
[5:04:31 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ℹ  Pushing backmerge to develop branch develop
[5:04:32 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ✖  Process aborted due to an error while backmerging a branch.
[5:04:32 PM] [semantic-release] [@saithodev/semantic-release-backmerge] › ✖  Error: Command failed with exit code 1: git push [REPO_URL] HEAD:develop 
To [REPO_URL]
 ! [rejected]        HEAD -> develop (non-fast-forward)
error: failed to push some refs to '[REPO_URL]'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

Can I solve it with this plugin or do I have to rebase the hotfixes manually?

saitho commented 2 years ago

Hi @ciltocruz,

this plugin is mainly a hacky way to achieve simple backmerges with semantic-release. So far, hotfixes have not been part of the scope. There's also a note in the readme about this:

Especially automatic hotfix releases may not be possible as those usually lead to merge conflicts with develop that have to be resolved manually. In such cases the release workflow will fail, causing a red pipeline!

But merge conflicts are not your issue. You're rebasing develop onto main, so commits in develop but not in master will get a new commit hash. You'd need to push that develop branch with -f for the push to get through; however this would also wipe other changes on the develop branch that are pushed during pipeline run.

Can you try to use backmergeStrategy: merge instead?

ciltocruz commented 2 years ago

Hello @saitho I tried. Unsuccessfully.

What I am doing now is that when this happens, then the pipeline fails but only because of the update of the develop branch on main. So what I do is do it manually.

Thanks!