Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "api/mapping/support/commonPushTests"

Index

Variables

Const AnyPush

AnyPush: PushTest = pushTest("Any push", async () => true)

Match on any push

param

Const FromAtomist

FromAtomist: PushTest = pushTest("Push from Atomist", async p =>p.push.after.message.includes("[atomist]"))

Is this a push originated by Atomist? Note that we can't look at the committer, as if a user invoked a command handler, their credentials will be used

param
returns

Const IsPushToBranchWithPullRequest

IsPushToBranchWithPullRequest: PushTest = pushTest("Push to branch with open pull request", async p => {if (p.push.branch === p.push.repo.defaultBranch) {return false;}const result = await p.context.graphClient.query<PullRequestsForBranch.Query, PullRequestsForBranch.Variables>({name: "PullRequestsForBranch",variables: {repo: p.push.repo.name,owner: p.push.repo.owner,branch: p.push.branch,},});const branch: PullRequestsForBranch.Branches = _.get(result, "Repo[0].branches[0]");if (branch && branch.pullRequests && branch.pullRequests.some(pr => pr.state === "open")) {return true;}return false;})

Is this push to a non-default branch that has an open pull request?

Const NonEmpty

NonEmpty: PredicatePushTest = predicatePushTest("NonEmpty",async p => (await p.totalFileCount()) > 0)

PushTest that returns true if project is non empty

Const ToDefaultBranch

ToDefaultBranch: PushTest = pushTest("Push to default branch", async p =>p.push.branch === p.push.repo.defaultBranch ||((!p.push.repo.defaultBranch || p.push.repo.defaultBranch.length === 0) && p.push.branch === "master"))

Functions

hasFile

hasFileContaining

  • hasFileContaining(pattern: string | string[], content?: RegExp): PushTest

hasFileWithExtension

hasResourceProvider

  • hasResourceProvider(type: "docker" | "npm" | "maven2", name?: string): PushTest

isBranch

isRepo

  • Return a push test that matches the repository owner/repo slug against regular expression.

    Parameters

    • re: RegExp

      Regular expression to match against using RegExp.test()

    Returns PushTest

    Push test performing the match

Generated using TypeDoc