Skip to content

Commit

Permalink
feat(2465): Prevent event's baseBranch from being null (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
itleigns authored Dec 5, 2023
1 parent f2ce8b7 commit b97205c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/eventFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b97205c

Please sign in to comment.