-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from Nr18/develop
Release v0.3.0
- Loading branch information
Showing
14 changed files
with
717 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,53 @@ | ||
from pull_request_codecommit.git import Commits | ||
from typing import Optional | ||
|
||
from .pull_request_codecommit import PullRequestCodeCommit | ||
from .pull_request_proposal import PullRequestProposal | ||
from .repository import Repository | ||
from .git import Commits | ||
|
||
|
||
class PullRequest: | ||
""" | ||
Understands pull requests | ||
""" | ||
|
||
def __init__(self, commits: Commits) -> None: | ||
self.__commits = commits | ||
def __init__(self, repo: Repository) -> None: | ||
self.__repo: Repository = repo | ||
self.__proposal: Optional[PullRequestProposal] = None | ||
self.__commits: Commits = self.__repo.commits() | ||
self.__pull_request: PullRequestCodeCommit = PullRequestCodeCommit( | ||
repository=repo | ||
) | ||
|
||
@property | ||
def has_changes(self) -> bool: | ||
return True if self.__commits.first else False | ||
def proposal(self) -> PullRequestProposal: | ||
if not self.__proposal: | ||
self.__proposal = PullRequestProposal(self.__pull_request, self.__commits) | ||
|
||
return self.__proposal | ||
|
||
@property | ||
def title(self) -> str: | ||
if not self.__commits.first: | ||
return "" | ||
return self.proposal.title | ||
|
||
title = self.__commits.first.message.subject | ||
|
||
if self.__commits.issues: | ||
title += f" ({', '.join(self.__commits.issues)})" | ||
@property | ||
def description(self) -> str: | ||
return self.proposal.description | ||
|
||
return title | ||
@property | ||
def link(self) -> str: | ||
return self.__pull_request.link | ||
|
||
@property | ||
def description(self) -> str: | ||
if len(self.__commits) == 1: | ||
description = ( | ||
[self.__commits.first.message.body] if self.__commits.first else [] | ||
) | ||
else: | ||
description = list( | ||
map(lambda commit: commit.message.subject, self.__commits) | ||
) | ||
|
||
if self.__commits.issues: | ||
description.append(f"\nIssues: " + ", ".join(self.__commits.issues)) | ||
|
||
return "\n".join(description).lstrip("\n") | ||
def has_changes(self) -> bool: | ||
return True if self.__commits.first else False | ||
|
||
def save(self) -> None: | ||
self.__repo.push() | ||
self.__pull_request.save(self.title, self.description) | ||
|
||
def update(self, title: str, description: str) -> None: | ||
self.proposal.update(title=title, description=description) | ||
|
||
def merge(self) -> str: | ||
return self.__pull_request.merge() |
Oops, something went wrong.