diff --git a/lib/eventFactory.js b/lib/eventFactory.js index c7882af1..de4a1910 100644 --- a/lib/eventFactory.js +++ b/lib/eventFactory.js @@ -709,8 +709,7 @@ class EventFactory extends BaseFactory { creator: config.creator || null, meta: config.meta || {}, pr: {}, - prNum, - baseBranch: config.baseBranch || null + prNum }; let prevChainPR = ''; let decoratedCommit; @@ -772,6 +771,17 @@ class EventFactory extends BaseFactory { } } + if (config.baseBranch) { + // cases triggered by webhook or when there is a parentEvent such as restart + modelConfig.baseBranch = config.baseBranch; + } else if (prInfo && prInfo.baseBranch) { + // cases of PR events created from the Start button + modelConfig.baseBranch = prInfo.baseBranch; + } else if (p.scmRepo && p.scmRepo.branch) { + // cases triggered by remote trigger and commit events created from the Start button + modelConfig.baseBranch = p.scmRepo.branch; + } + if (prTitle) { modelConfig.pr.title = prTitle; }