Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DiffSize

This Bot Action class analyzes how many lines of diff are contained in the GitLab Merge Request and determines what, if any, feedback to provide to user.

Hierarchy

  • DiffSize

Index

Properties

Static Readonly badNote

badNote: string = `:loudspeaker: This merge request is larger than one person can handle. ` +`Why not call in a partner and keep your branches smaller?`

Static Readonly botActionName

botActionName: "DiffSize" = "DiffSize"

Static Readonly goodNote

goodNote: ":star: Great job keeping your merge requests manageable!" = `:star: Great job keeping your merge requests manageable!`

Static Readonly hashtag

hashtag: "[#DiffAnalysis](https://github.com/Cigna/GitRDoneBot#1-diff-size)" = `[#DiffAnalysis](https://github.com/Cigna/GitRDoneBot#1-diff-size)`

Static Readonly zeroNote

zeroNote: ":star: Great idea creating a MR right away from a branch/issue!" = `:star: Great idea creating a MR right away from a branch/issue!`

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 Diff Size analysis

Static buildSuccessfulAction

  • buildSuccessfulAction(state: string, totalDiffs: number, 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

    • totalDiffs: number

      total lines of diff in the Merge Request

    • goodGitPractice: boolean

      represents whether or not the Merge Request event meets the criteria for good Diff Size 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 Private calculateDiffs

  • calculateDiffs(changes: Array<Change>): number
  • Calculates the total lines of diff as the sum of additions and deletions across all of the Change objects.

    Parameters

    • changes: Array<Change>

      array of GitLab Change objects

    Returns number

    total lines of diff across all of the changes

Static caseForBadMessage

  • caseForBadMessage(goodGitPractice: boolean): boolean

Static caseForGoodMessage

  • caseForGoodMessage(state: string, totalDiffs: number, goodGitPractice: boolean, constructiveFeedbackOnlyToggle: boolean): boolean
  • Parameters

    • state: string
    • totalDiffs: number
    • goodGitPractice: boolean
    • constructiveFeedbackOnlyToggle: boolean

    Returns boolean

Static caseForZeroMessage

  • caseForZeroMessage(state: string, totalDiffs: number, goodGitPractice: boolean, constructiveFeedbackOnlyToggle: boolean): boolean
  • Parameters

    • state: string
    • totalDiffs: number
    • goodGitPractice: boolean
    • constructiveFeedbackOnlyToggle: boolean

    Returns boolean

Static Private customParser

  • customParser(diff: string): number

Generated using TypeDoc