Skip to content
Snippets Groups Projects
Commit 7bb51fc6 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Refactored field names for consistency

parent d67d9862
No related branches found
No related tags found
No related merge requests found
...@@ -208,35 +208,35 @@ class GitlabIssue: ...@@ -208,35 +208,35 @@ class GitlabIssue:
class GitlabCommit: class GitlabCommit:
gitlab_commit: ProjectCommit git_commit: ProjectCommit
# noinspection PyShadowingNames # noinspection PyShadowingNames
def __init__(self, commit: ProjectCommit): def __init__(self, commit: ProjectCommit):
super().__init__() super().__init__()
self.gitlab_commit = commit self.git_commit = commit
def get_author(self) -> Dict[str, str]: def get_author(self) -> Dict[str, str]:
return {'name': self.gitlab_commit.author_name, 'email': self.gitlab_commit.author_email} return {'name': self.git_commit.author_name, 'email': self.git_commit.author_email}
def get_timestamp(self) -> datetime: def get_timestamp(self) -> datetime:
return datetime.fromisoformat(self.gitlab_commit.created_at) return datetime.fromisoformat(self.git_commit.created_at)
def get_message(self) -> str: def get_message(self) -> str:
return self.gitlab_commit.message return self.git_commit.message
def is_merge(self) -> bool: def is_merge(self) -> bool:
return len(self.gitlab_commit.parent_ids) > 1 return len(self.git_commit.parent_ids) > 1
def get_id(self) -> str: def get_id(self) -> str:
return self.gitlab_commit.id return self.git_commit.id
def get_short_id(self) -> str: def get_short_id(self) -> str:
return self.gitlab_commit.short_id return self.git_commit.short_id
# noinspection PyShadowingNames # noinspection PyShadowingNames
def get_diffs(self) -> List[Dict[str, Union[str, int]]]: def get_diffs(self) -> List[Dict[str, Union[str, int]]]:
diffs: List[Dict[str, Union[str, int]]] = [] diffs: List[Dict[str, Union[str, int]]] = []
gitlab_diffs: List[Dict[str, str]] = self.gitlab_commit.diff() gitlab_diffs: List[Dict[str, str]] = self.git_commit.diff()
for diff in gitlab_diffs: for diff in gitlab_diffs:
diffs.append({'file': diff['new_path'], 'text': diff['diff'], diffs.append({'file': diff['new_path'], 'text': diff['diff'],
'+': diff['diff'].count('\n+'), '-': diff['diff'].count('\n-')}) '+': diff['diff'].count('\n+'), '-': diff['diff'].count('\n-')})
...@@ -306,7 +306,7 @@ class GitlabCommit: ...@@ -306,7 +306,7 @@ class GitlabCommit:
def detail_formatting_problems(self, subject_line_length=72, message_line_length=72) -> str: def detail_formatting_problems(self, subject_line_length=72, message_line_length=72) -> str:
lines: List[str] = self.get_message().rstrip('\n').split('\n') lines: List[str] = self.get_message().rstrip('\n').split('\n')
commit_id: str = f'Commit {self.gitlab_commit.short_id}' commit_id: str = f'Commit {self.git_commit.short_id}'
if self.is_well_formatted(): if self.is_well_formatted():
return f'{commit_id} is well-formatted' return f'{commit_id} is well-formatted'
else: else:
...@@ -349,17 +349,17 @@ class GitlabCommit: ...@@ -349,17 +349,17 @@ class GitlabCommit:
class GitlabMilestone: class GitlabMilestone:
gitlab_milestone: ProjectMilestone git_milestone: ProjectMilestone
def __init__(self, milestone: ProjectMilestone): def __init__(self, milestone: ProjectMilestone):
super().__init__() super().__init__()
self.gitlab_milestone = milestone self.git_milestone = milestone
def get_issues(self) -> List[GitlabIssue]: def get_issues(self) -> List[GitlabIssue]:
""" """
:return: List of Issue objects representing project's issues :return: List of Issue objects representing project's issues
""" """
gitlab_issues: Iterable[Issue] = self.gitlab_milestone.issues() gitlab_issues: Iterable[Issue] = self.git_milestone.issues()
issues: List[GitlabIssue] = [] issues: List[GitlabIssue] = []
for issue in gitlab_issues: for issue in gitlab_issues:
issues.append(GitlabIssue(issue)) issues.append(GitlabIssue(issue))
...@@ -369,35 +369,35 @@ class GitlabMilestone: ...@@ -369,35 +369,35 @@ class GitlabMilestone:
""" """
:return: True if the milestone is active; False if the milestone is closed :return: True if the milestone is active; False if the milestone is closed
""" """
return self.gitlab_milestone.state == 'active' return self.git_milestone.state == 'active'
def is_closed(self) -> bool: def is_closed(self) -> bool:
""" """
:return: True if the milestone is closed; False if the milestone is active :return: True if the milestone is closed; False if the milestone is active
""" """
return self.gitlab_milestone.state == 'closed' return self.git_milestone.state == 'closed'
def close(self) -> None: def close(self) -> None:
self.gitlab_milestone.state_event = 'close' self.git_milestone.state_event = 'close'
self.gitlab_milestone.save() self.git_milestone.save()
def get_title(self) -> str: def get_title(self) -> str:
""" """
:return: The milestone's title :return: The milestone's title
""" """
return self.gitlab_milestone.title return self.git_milestone.title
def get_description(self) -> str: def get_description(self) -> str:
""" """
:return: The milestone's description :return: The milestone's description
""" """
return self.gitlab_milestone.description return self.git_milestone.description
def get_created_at(self) -> date: def get_created_at(self) -> date:
""" """
:return: a date object representing the start date :return: a date object representing the start date
""" """
date_segments: List[str] = self.gitlab_milestone.start_date.split('-') date_segments: List[str] = self.git_milestone.start_date.split('-')
year = int(date_segments[0]) year = int(date_segments[0])
month = int(date_segments[1]) month = int(date_segments[1])
day = int(date_segments[2]) day = int(date_segments[2])
...@@ -407,7 +407,7 @@ class GitlabMilestone: ...@@ -407,7 +407,7 @@ class GitlabMilestone:
""" """
:return: a date object representing the due date :return: a date object representing the due date
""" """
date_segments: List[str] = self.gitlab_milestone.due_date.split('-') date_segments: List[str] = self.git_milestone.due_date.split('-')
year = int(date_segments[0]) year = int(date_segments[0])
month = int(date_segments[1]) month = int(date_segments[1])
day = int(date_segments[2]) day = int(date_segments[2])
...@@ -416,7 +416,7 @@ class GitlabMilestone: ...@@ -416,7 +416,7 @@ class GitlabMilestone:
def __repr__(self) -> str: def __repr__(self) -> str:
return self.get_title() return self.get_title()
# other gitlab_milestone fields: # other git_milestone fields:
# id # id
# iid # iid
# project_id # project_id
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment