Skip to content

Add support to manage issue/pull request/discussion locks #5020

Description

@glensc

Describe the feature or problem you’d like to solve

gh pr lock 123 -m resolved
gh issue lock 123 -m off-topic
gh issue unlock 123

Proposed solution

Sometimes people continue the discussion on closed issues, so it's better to lock them as closed issues and pull requests are not visible for project maintainers.

Additional context

There are github actions, but doing this one time for bulk of issues is easier to do some cli scripting than setup github actions.

Activity

  1. added
    discussFeature changes that require discussion primarily among the GitHub CLI team
    and removed on Jan 11, 2022
  2. mislav commented on Jan 11, 2022

    @mislav
    Contributor

    Note that you can currently lock/unlock issues via the gh api command:

    gh api -X PUT repos/{owner}/{repo}/issues/123/lock -f lock_reason=resolved
    
    gh api -X DELETE repos/{owner}/{repo}/issues/123/lock
    

    We could consider adding dedicated commands for this.

  3. removed
    discussFeature changes that require discussion primarily among the GitHub CLI team
    on Jan 19, 2022
  4. added
    coreThis issue is not accepting PRs from outside contributors
    on Jan 19, 2022
  5. vilmibm commented on Jan 19, 2022

    @vilmibm
    Contributor

    Let's do this, adding unlock and lock to issue and pr.

    For whoever picks this up: to reduce boilerplating and test effort, support for this should be contained in a single new command (which can lock/unlock both issues and prs) mounted at the four places it's needed via cobra.

    If this is unclear, reach out to us for help.

  6. added and removed
    coreThis issue is not accepting PRs from outside contributors
    on Jan 19, 2022
  7. chemotaxis commented on Jan 23, 2022

    @chemotaxis
    Contributor

    I can take a look into this, if no one has started or claimed it.

  8. chemotaxis commented on Jan 25, 2022

    @chemotaxis
    Contributor

    @vilmibm

    After looking over the issue and pr commands, I have a couple questions:

    1. Conceptually, I understand that I should write a single function or command that gets aliased to lock and unlock. Where should I put that single function? I see that there are shared directories in both issue and pr. Should I be putting it one of those shared directories?
    2. Are there similar commands that I can take a look at that do similar functionality and api requests? I just want to make sure I'm using the correct modules for authentication, api requests, etc.
  9. mislav commented on Feb 1, 2022

    @mislav
    Contributor

    @chemotaxis You can start a pkg/cmd/issue/lock package and have it export a method like NewCmdLock(). The method could take an argument to either "lock" or "unlock" and return a *cobra.Command. With that, you can mount that Cobra command four times: to issue lock, issue unlock, pr lock, and pr unlock.

    Sure, you could also add that method to the shared package, but I think having an explicit lock package in accordance to the naming scheme of other command implementations will make it more discoverable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIhelp wantedContributions welcome

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions