RealDevSquad / RealDevSquad/website-backend

[RFC]: GitHub API Patch Request for Adding or Removing Labels on Pull Requests

Open
#1,138 0 comments 0 reactions 1 assignee View on GitHub

@sahsisunny is already working on this.

Since Jun 5, 2023.

Dominant language
JavaScript
Stars
74
Forks
276
Avg merge
1d 26m
Merged PRs (30d)
14

Description

[RFC]: GitHub API Patch Request for Adding or Removing Labels on Pull Requests

Summary:

This RFC proposes a standard format for sending PATCH requests to the GitHub API in order to add or remove labels on pull requests (PRs). The intention is to enable seamless integration with our Real Dev Squad backend, allowing us to mark PRs as "dev to main sync" and collapse related tasks.

Motivation:

When SUPER USER viewing the member's details page, he sees a list of tasks and PRs that are assigned to him. However, he is only interested in a few of them and wants to focus on those tasks or PRs. He finds that the other tasks or PRs are distracting and would like to hide them. SUPER USER would like to collapse the non-interesting tasks or PRs so that he can focus on the relevant ones.

Specification

To add or remove labels on a PR, we will use the PATCH method provided by the GitHub API. The following endpoints and parameters should be utilized:

Endpoint for adding labels: PATCH /repos/{owner}/{repo}/issues/{issue_number}

Request Headers

Content-Type: application/json
Authorization: Bearer {access_token}
  • owner: The owner of the repository. Example: Real-Dev-Squad [REQUIRED]
  • repo: The name of the repository. Example: website-status [REQUIRED]
  • issue_number: The number of the issue or PR. Example: 124 [REQUIRED]

Request Body

The request body should contain the desired changes to the labels. The format is as follows:

{
  "labels": ["Dev to Main Sync"]
}

Endpoint for removing labels: DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}

Request Headers

Content-Type: application/json
Authorization: Bearer {access_token}
  • owner: The owner of the repository. Example: Real-Dev-Squad [REQUIRED]
  • repo: The name of the repository. Example: website-status [REQUIRED]
  • issue_number: The number of the issue or PR. Example: 124 [REQUIRED]
  • name: The name of the label to remove. Example: Dev to Main Sync [REQUIRED]

Request Body

The request body should be empty.

How this will be implemented

All PATCH and DELETE requests will be sent to the GitHub API by Real Dev Squad backend endpoints. The endpoints will be called by the frontend when a user clicks the "Collapse" button on a task or PR. The backend will then send the PATCH or DELETE request to the GitHub API, and the task or PR will be collapsed.

sequenceDiagram
    participant Frontend
    participant Backend
    participant GitHub API

    Frontend->>Backend: Clicks "Collapse" button
    Backend->>GitHub API: Send PATCH request to add/remove label
    GitHub API-->>Backend: Respond with success message
    Backend-->>Frontend: Return success response

    Note over Frontend, Backend: Collapse task/PR on the UI

Conclusion

This RFC proposes a standard format for sending PATCH requests to the GitHub API in order to add or remove labels on pull requests (PRs). The intention is to enable seamless integration with our Real Dev Squad backend, allowing us to mark PRs as "dev to main sync" and collapse-related tasks.

Links

https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.