Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BranchAge

This Bot Action class analyzes the age of the Commits contained in the GitLab Merge Request and determines what, if any, feedback to provide to user.

Hierarchy

  • BranchAge

Index

Properties

Static Readonly badNote

badNote: string = `:loudspeaker: This merge request has a pretty old commit. ` +`You should try and merge more frequently to keep your commits on branches fresh.`

Static Readonly botActionName

botActionName: "BranchAge" = "BranchAge"

Static Readonly goodNote

goodNote: string = `:star: It’s great that you’re committing and merging code frequently` +` - the commits on this branch aren’t old or stale. Good job!`

Static Readonly hashtag

hashtag: "[#BranchAgeAnalysis](https://github.com/Cigna/GitRDoneBot#2-branch-age)" = `[#BranchAgeAnalysis](https://github.com/Cigna/GitRDoneBot#2-branch-age)`

Methods

Static analyze

  • Parameters

    • state: string

      the state of the Merge Request: open, update, or merge

    • api: GitLabApi

      an instance of GitLabApi

    • customConfig: BotActionConfig

      an instance of BotActionConfig

    Returns Promise<BotActionResponse>

    data about the success or failure of the GitLab API request and resulting properties calculated by Branch Age analysis

Static buildSuccessfulAction

  • buildSuccessfulAction(state: string, goodGitPractice: boolean, constructiveFeedbackOnlyToggle: boolean): SuccessfulBotAction
  • Invoked when Bot Action analysis was successful. Constructs a BotAction object containing goodGitPractice and conditional feedback message.

    Parameters

    • state: string

      the state of the Merge Request: open, update, or merge

    • goodGitPractice: boolean

      represents whether or not the Merge Request event meets the criteria for good Branch Age practice

    • constructiveFeedbackOnlyToggle: boolean

      if true, positive feedback will not be provided

    Returns SuccessfulBotAction

    SuccessfulBotActionWithMessage instance containing feedback for user. If no feedback is warranted, an instance of SuccessfulBotActionWithNothingToSay is returned.

Static caseForBadMessage

  • caseForBadMessage(goodGitPractice: boolean): boolean

Static caseForGoodMessage

  • caseForGoodMessage(state: string, goodGitPractice: boolean, constructiveFeedbackOnlyToggle: boolean): boolean

Static getOldestCommit

Static isBranchYoungerThanThreshold

  • isBranchYoungerThanThreshold(oldestCommit: GitLabCommit, threshold: number): boolean
  • Parameters

    • oldestCommit: GitLabCommit

      a single Commit object

    • threshold: number

      the number of days to compare the age of the Commit to

    Returns boolean

    true if age of oldestCommit is less than threshold

Generated using TypeDoc