fix: return correct NX_BASE SHA for merge_group event#145
fix: return correct NX_BASE SHA for merge_group event#145
Conversation
|
Closed since I couldn't test enough scenarios |
| return result ? result.at(1) : undefined; | ||
| } | ||
|
|
||
| async function findMergeQueueBranch(): Promise<string> { |
There was a problem hiding this comment.
In merge-queue scenario, base will always be the previous commit in the queue. That's why we can remove these functions here.
| const baseResult = spawnSync('git', ['merge-base', `origin/${mainBranchName}`, 'HEAD'], { encoding: 'utf-8' }); | ||
| BASE_SHA = baseResult.stdout; | ||
| } else if (eventName == "merge_group") { | ||
| const baseResult = spawnSync('git', ['rev-parse', 'HEAD^1'], { encoding: 'utf-8' }); |
There was a problem hiding this comment.
In merge-queue scenario, base will always be the previous commit in the queue.
|
@mandarini would appreciate your review |
|
We had to fork to pull in this patch (it's working great for us), it would be nice to get it integrated into the real action at some point soon. |
Hey everyone! Sorry for the delay in getting a review on this. We've all been super swamped on other initiatives. Luckily I'm hoping to take a look at this soon |
|
Looks good to me, thank you! |
Context
As reported in #140, the current solution for merge-queue works only when the queue size 1. When more commits are added to the queue, the action keeps setting the same
NX_BASEfor all of them.Problem
When new commits are added to the queue, we expect the
NX_BASEcommit to be the last commit in the queue. However, it sets the last commit in master. This image from #140 (comment) represents well the problem.Solution proposed
The
NX_BASEcommit should be main branch HEAD commit when merge-queue has size 1. When size > 1,NX_BASEshould be the HEAD commit of the last merge branch that current commit is on top of.Fixes #140