Skip to content

Commit

Permalink
Merge pull request #33 from Nr18/fix/remove-remote-branch
Browse files Browse the repository at this point in the history
fix: delete the remote branch when pull request is merged
  • Loading branch information
Joris Conijn committed Feb 12, 2022
2 parents 1c4b105 + 117661f commit d16cb0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pull_request_codecommit/aws/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def update_pull_request(

return data.get("pullRequest")

def merge_pull_request(self, repository: str, pull_request_id: int) -> dict:
def merge_pull_request(
self, repository: str, pull_request_id: int, branch: str
) -> dict:
response = self.__execute(
[
"codecommit",
Expand All @@ -131,5 +133,18 @@ def merge_pull_request(self, repository: str, pull_request_id: int) -> dict:
]
)
data = json.loads(response)

return data.get("pullRequest")
pull_request = data.get("pullRequest")

if pull_request.get("pullRequestStatus", "") == "CLOSED":
self.__execute(
[
"codecommit",
"delete-branch",
"--repository-name",
repository,
"--branch-name",
branch,
]
)

return pull_request
1 change: 1 addition & 0 deletions pull_request_codecommit/pull_request_codecommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def merge(self) -> str:
response = self.__client.merge_pull_request(
repository=self.__repo.remote.name,
pull_request_id=self.pull_request_id,
branch=self.__repo.branch,
)
status = response.get("pullRequestStatus", "")

Expand Down

0 comments on commit d16cb0e

Please sign in to comment.