Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CommitMessages

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

Hierarchy

  • CommitMessages

Index

Properties

Static Readonly badNote

badNote: ":loudspeaker: Keep commits descriptive and concise - more than one word and between 3 and 50 characters" = `:loudspeaker: Keep commits descriptive and concise - more than one word and between 3 and 50 characters`

Static botActionName

botActionName: string = "CommitMessages"

Static Readonly goodNote

goodNote: ":star: Nice work following your team's commit message style conventions!" = `:star: Nice work following your team's commit message style conventions!`

Static Readonly hashtag

hashtag: "[#CommitMessage](https://github.com/Cigna/GitRDoneBot#5-commit-messages)" = `[#CommitMessage](https://github.com/Cigna/GitRDoneBot#5-commit-messages)`

Static Private minimumThreshold

minimumThreshold: number = 2

Methods

Static analyze

  • Parameters

    • state: string

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

    • api: GitLabApi

      an instance of GitLabApi

    Returns Promise<BotActionResponse>

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

Static buildSuccessfulAction

  • 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 Commit Messages practice

    Returns SuccessfulBotAction

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

Static Private calculateThreshold

  • calculateThreshold(totalCommits: number): number
  • Computes the threshold (number of offenses required to give a "nudge") Since MRs can be of many different sizes, it makes sense to evaluate the user based on the percentage of correct commits.

    If we do this, though, we run into strange behavior when there are very few commits.

    So, we define both a universal minimum threshold and a percentage of commits. The "threshold" is the higher of these two numbers.

    Parameters

    • totalCommits: number

      Number of commits used in this merge request

    Returns number

Static caseForBadMessage

  • caseForBadMessage(goodGitPractice: boolean): boolean

Static caseForGoodMessage

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

Static Private isOneWord

  • isOneWord(title: string): boolean

Static Private lengthValid

  • lengthValid(message: string): boolean
  • Returns whether a string follows the length convention

    Parameters

    • message: string

    Returns boolean

    True if the string has at least 4 alphanumeric characters and at most 50 of any type of character.

Static Private testThreshold

  • testThreshold(grammarParam: Array<boolean>, threshold: number): boolean
  • Parameters

    • grammarParam: Array<boolean>

      Ordered array indicating whether each commit followed (true) or violated (false) this convention

    • threshold: number

      Obtained by the calculateThreshold function

    Returns boolean

Generated using TypeDoc