Close a pull request in an Amazon CodeCommit repository - Amazon CodeCommit
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Close a pull request in an Amazon CodeCommit repository

If you want to close a pull request without merging the code, you can do so in one of several ways:

  • In the console, you can close a pull request without merging the code. You might want to do this if you want to use the git merge command to merge the branches manually, or if the code in the pull request source branch isn't code you want merged into the destination branch.

  • You can delete the source branch specified in the pull request. CodeCommit closes a pull request automatically if either the source or destination branch of the pull request is deleted.

  • In the Amazon CLI, you can update the status of a pull request from OPEN to CLOSED. This closes the pull request without merging the code.

Close a pull request (console)

You can use the CodeCommit console to close a pull request in a CodeCommit repository. After the status of a pull request is changed to Closed, it cannot be changed back to Open, but users can still comment on the changes and reply to comments.

  1. Open the CodeCommit console at https://console.www.amazonaws.cn/codesuite/codecommit/home.

  2. In Repositories, choose the name of the repository.

  3. In the navigation pane, choose Pull requests.

  4. By default, a list of all open pull requests is displayed. Choose the open pull request you want to close.

    
            Pull requests displayed in the CodeCommit console.
  5. In the pull request, choose Close pull request. This option closes the pull request without attempting to merge the source branch into the destination branch. This option does not provide a way to delete the source branch as part of closing the pull request, but you can do it yourself after the request is closed.

Close a pull request (Amazon CLI)

To use Amazon CLI commands with CodeCommit, install the Amazon CLI. For more information, see Command line reference.

To use the Amazon CLI to close pull requests in a CodeCommit repository

  • To update the status of a pull request in a repository from OPEN to CLOSED, run the update-pull-request-status command, specifying:

    • The ID of the pull request (with the --pull-request-id option).

    • The status of the pull request (with the --pull-request-status option).

    For example, to update the status of a pull request with the ID of 42 to a status of CLOSED in a CodeCommit repository named MyDemoRepo:

    aws codecommit update-pull-request-status --pull-request-id 42 --pull-request-status CLOSED

    If successful, this command produces output similar to the following:

    { "pullRequest": { "approvalRules": [ { "approvalRuleContent": "{\"Version\": \"2018-11-08\",\"Statements\": [{\"Type\": \"Approvers\",\"NumberOfApprovalsNeeded\": 2,\"ApprovalPoolMembers\": [\"arn:aws:sts::123456789012:assumed-role/CodeCommitReview/*\"]}]}", "approvalRuleId": "dd8b17fe-EXAMPLE", "approvalRuleName": "2-approvers-needed-for-this-change", "creationDate": 1571356106.936, "lastModifiedDate": 571356106.936, "lastModifiedUser": "arn:aws:iam::123456789012:user/Mary_Major", "ruleContentSha256": "4711b576EXAMPLE" } ], "authorArn": "arn:aws:iam::123456789012:user/Li_Juan", "clientRequestToken": "", "creationDate": 1508530823.165, "description": "Updated the pull request to remove unused global variable.", "lastActivityDate": 1508372423.12, "pullRequestId": "47", "pullRequestStatus": "CLOSED", "pullRequestTargets": [ { "destinationCommit": "9f31c968EXAMPLE", "destinationReference": "refs/heads/main", "mergeMetadata": { "isMerged": false, }, "repositoryName": "MyDemoRepo", "sourceCommit": "99132ab0EXAMPLE", "sourceReference": "refs/heads/variables-branch" } ], "title": "Consolidation of global variables" } }