-
Notifications
You must be signed in to change notification settings - Fork 64
/
upToDateBranch.ts
27 lines (24 loc) · 900 Bytes
/
upToDateBranch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { HandlerContext, PullRequestInfo } from '../models'
import { ConditionResult } from '../condition'
export default function hasUpToDateBranch (
context: HandlerContext,
pullRequestInfo: PullRequestInfo
): ConditionResult {
const protectedBranch = pullRequestInfo.repository.protectedBranches.nodes
.filter(protectedBranch => protectedBranch.name === pullRequestInfo.baseRef.name)[0]
if (protectedBranch
&& protectedBranch.hasStrictRequiredStatusChecks
&& pullRequestInfo.baseRef.target.oid !== pullRequestInfo.baseRefOid) {
return {
status: 'fail',
message: `Pull request is based on a strict protected branch (${
pullRequestInfo.baseRef.name
}) and base sha of pull request (${
pullRequestInfo.baseRefOid
}) differs from sha of branch (${pullRequestInfo.baseRef.target.oid})`
}
}
return {
status: 'success'
}
}