Skip to content

Latest commit

 

History

History
191 lines (154 loc) · 7.36 KB

cEP-0036.md

File metadata and controls

191 lines (154 loc) · 7.36 KB

Gitmate for coala

Metadata
cEP 36
Version 1.0
Title Gitmate for coala
Authors Sanchit Gupta mailto:sanchitgupta.072@gmail.com
Status Implementation Due
Type Process

Abstract

This cEP describes the improvements to IGitt and Gitmate, which include upgrading dependencies, making it functional, changes to plugins, etc. as a part of the GSoC'21 project.

Introduction

Gitmate, a git workflow management bot created by coala, hasn't been actively maintained in the last 3 years. It needs to be updated it and brought back to active use. Various improvements need to be made to Gitmate as well as IGitt, the underlying library that powers Gitmate's git operations.

Upgrade Dependencies

IGitt and Gitmate are both severely outdated in terms of dependencies. Support needs to be added for the latest versions of python, and most packages need to be updated to their latest versions. IGitt is currently using Jira API v2 which can be upgraded to v3. Currently, Angular is running v4. It needs fundamental changes to upgrade it to v12.

Changes to IGitt

  • Docstrings, wherever missing, need to be added to the IGitt codebase.
  • IGitt documentation needs to be updated to reflect changes occurring due to migration from Gitmate to coala organisation. Also, a section can be added on how IGitt codebase is structured, examples can be written for those actions missing currently like notifications, reactions etc, and a section on how to use and set up and use for developers can be added too.
  • Cron jobs are currently missing for different versions of python, so they need to be added after adding support for latest versions.
  • coala-IGitt needs to be published as a separate package.

Changes to Gitmate

Fix CI/CD and make Gitmate functional

Firstly, cron jobs need to be added for all the supported versions of python. Also, Gitmate hosting needs to be migrated to a new domain before we activate Gitmate.

Improve frontend

Multiple improvements can be made to the frontend. These include UI changes such as:

Frontend documentation can be improved and the following changes can be made:

  • Improve developers section - Fix broken links, improve part about setting environment variables
  • Complete FAQ.md
  • Add a section on how the Gitmate codebase is structured.

Changes to backend

  • Docstrings, wherever missing, need to be added to the backend codebase.
  • The ‘ack’, ‘approver’, and ‘auto label pending or wip’ plugins need to be merged into a combined 'review' plugin. The models for the combined review plugins should be similar to this:
class Settings(SettingsBase):
    wip_label = models.CharField(
        max_length=25,
        default='status/WIP',
        help_text='Label for pull requests that are work in progress')
    pending_review_label = models.CharField(
        max_length=25,
        default='status/pending_review',
        help_text='Label for pull requests that need review')
    approved_label = models.CharField(
        max_length=25,
        default='status/approved',
        help_text='Label for pull requests that have been approved')
    ack_strs = models.TextField(
        default='ack, reack',
        help_text='Keywords for acknowledging commits, comma separated')
    unack_strs = models.TextField(
        default='unack',
        help_text='Keywords for unacknowledging commits, comma separated')
class MergeRequestModel(models.Model):
    repo = models.ForeignKey(
        Repository, on_delete=models.CASCADE, related_name='review_mr')
    number = models.IntegerField()
    acks = psql_fields.JSONField(default=dict)
    head_sha = models.CharField(max_length=40, default='')

    @property
    def ack_state(self):
        state = CommitStatus(
            Status.SUCCESS, 'This PR is reviewed. :)',
            'review/gitmate/manual/pr', 'https://gitmate.io')
        for acked in dict(self.acks).values():
            if acked['status'] in [Status.FAILED.value,
                                   Status.ERROR.value,
                                   Status.CANCELED.value]:
                return CommitStatus(
                    Status.FAILED, 'This PR needs work. :(',
                    'review/gitmate/manual/pr', 'https://gitmate.io')
            if acked['status'] == Status.PENDING.value:
                state = CommitStatus(
                    Status.PENDING, 'This PR needs review.',
                    'review/gitmate/manual/pr', 'https://gitmate.io')

        return state

    @property
    def igitt_pr(self):
        return self.repo.igitt_repo.get_mr(self.number)
  • The rebaser plugin needs to be changed to ensure that the proper labels are applied when rebase, fastforward, or merge is performed. The following functions must be added in responders.py of rebaser plugin:
def verify_appropriate_label(cmd: str,
                             pr: MergeRequest,
                             wip_label: str = 'status/WIP',
                             pending_review_label: str = 'status/pending_review',
                             approved_label: str = 'status/approved'):
    if(cmd == 'rebase'):
        return True
    labels = pr.labels
    if not approved_label in labels:
        return False
def handle_command_fail(pr: MergeRequest,
                        wip_label: str = 'status/WIP',
                        pending_review_label: str = 'status/pending_review',
                        approved_label: str = 'status/approved'):
    labels = pr.labels
    if not wip_label in labels:
        if pending_review_label in labels:
            labels.discard(pending_review_label)
        else:
            labels.discard(approved_label)
        labels.add(wip_label)