Skip to content

Commit

Permalink
Merge pull request #36 from Nr18/develop
Browse files Browse the repository at this point in the history
Release 0.3.1
  • Loading branch information
Joris Conijn authored Feb 19, 2022
2 parents c601f08 + 7f9a46b commit 0d1327b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 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
2 changes: 1 addition & 1 deletion pull_request_codecommit/git/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def current_branch(self) -> str:

def get_commit_messages(self, destination_branch: str) -> Commits:
messages = self.__execute(
["log", f"{destination_branch}..{self.current_branch}"]
["log", f"origin/{destination_branch}..{self.current_branch}"]
)

return Commits(messages)
Expand Down
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pull-request-codecommit"
version = "0.3.0"
version = "0.3.1"
description = "pull-request-codecommit creates a PR within CodeCommit based on your commit messages."
authors = ["Joris Conijn <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 0d1327b

Please sign in to comment.