Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SelfMerge

This Bot Action class analyzes the assignee or the approvers and the user who merged the GitLab Merge Request and determines what, if any, feedback to provide to user.

Hierarchy

  • SelfMerge

Index

Properties

Static Readonly badApprovedNote

badApprovedNote: string = `:loudspeaker: You should re-open this merge request and have someone else review and approve it. ` +`You can check your project settings to make sure self approval of merge requests is not enabled. ` +`You can find this in Settings -> General -> Merge Request`

Static Readonly badAssignedNote

badAssignedNote: string = `:loudspeaker: I noticed that you assigned your merge request to yourself. ` +`This is an unsafe practice that circumvents quality code review. You can check your project` +` settings to make sure self approval of merge requests is not enabled. You can find this in` +` Settings -> General -> Merge Request`

Static Readonly badMergedNote

badMergedNote: string = `:loudspeaker: You should re-open this merge request and have someone else review and approve it. ` +`You can check your project settings to make sure at least 1 approval is required to merge in new code. ` +`Project settings can be updated to require approvals in Settings -> General -> Merge Request`

Static Readonly botActionName

botActionName: "SelfMerge" = "SelfMerge"

Static Readonly goodNote

goodNote: ":star: Thanks for following good git practice and not assigning your merge request to yourself!" = `:star: Thanks for following good git practice and not assigning your merge request to yourself!`

Static Readonly hashtag

hashtag: "[#SelfMergeAnalysis](https://github.com/Cigna/GitRDoneBot#3-self-merge)" = `[#SelfMergeAnalysis](https://github.com/Cigna/GitRDoneBot#3-self-merge)`

Static Readonly noApprovalsNote

noApprovalsNote: string = `:loudspeaker: I noticed that your project doesn't require any approvals to merge in your code. ` +`It is a good practice to require at least 1 approval to prevent accidentally merging code that hasn't been reviewed by others.` +`Project settings can be updated to require approvals in Settings -> General -> Merge Request`

Methods

Static analyze

  • Parameters

    • state: string

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

    • api: GitLabApi

      an instance of GitLabApi

    • assigneeId: number

      GitLab user id of the Merge Request assignee

    • authorId: number

      GitLab user id of the Merge Request author

    Returns Promise<BotActionResponse>

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

Static buildSuccessfulAction

  • buildSuccessfulAction(state: string, goodGitPractice: boolean, approversNeeded: 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 Self Merge practice

    • approversNeeded: boolean

    Returns SuccessfulBotAction

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

Static caseForBadSelfApprovedMessage

  • caseForBadSelfApprovedMessage(state: string, goodGitPractice: boolean, approversNeeded: boolean): boolean

Static caseForBadSelfAssignedMessage

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

Static caseForBadSelfMergedMessage

  • caseForBadSelfMergedMessage(state: string, goodGitPractice: boolean, approversNeeded: boolean): boolean

Static caseForGoodMessage

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

Static caseForNoApprovalsMessage

  • caseForNoApprovalsMessage(state: string, goodGitPractice: boolean, approversNeeded: boolean): boolean

Static Private mrIsNotSelfApproved

  • mrIsNotSelfApproved(approvedByArray: Array<{ user: User }>, authorId: number): boolean
  • Parameters

    • approvedByArray: Array<{ user: User }>

      array of GitLab users who approved the GitLab Merge Request

    • authorId: number

      the GitLab id of the user who authored the Merge Request

    Returns boolean

    true if the author of the GitLab Merge Request is not the only user in the approvedByArray

Static Private mrIsNotSelfAssignedOrMerged

  • mrIsNotSelfAssignedOrMerged(assigneeOrMergerId: number, authorId: number): boolean

Generated using TypeDoc