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

Added equality methods to GitlabIssue, GitlabCommit, and GitlabMilestone

parent 1d9a3ded
Branches
Tags
No related merge requests found
......@@ -111,7 +111,7 @@ class GitlabIssue:
"""
return self.git_issue.description
@deprecated
@deprecated(reason='Use is_open() or is_closed()')
def get_state(self) -> str: # TODO, delete after we're sure there are no uses
"""
:return: opened or closed
......@@ -196,6 +196,12 @@ class GitlabIssue:
title = self.get_title()
return f'{issue_number}. {title}'
def __eq__(self, other: "GitlabIssue") -> bool:
return self.get_universal_issue_id() == other.get_universal_issue_id()
def __ne__(self, other: "GitlabIssue") -> bool:
return not self.__eq__(other)
# other git_issue fields:
# project_id
# title
......@@ -320,7 +326,7 @@ class GitlabCommit:
def detail_formatting_problems(self, subject_line_length=72, message_line_length=72) -> str:
lines: List[str] = self.get_message().rstrip('\n').split('\n')
commit_id: str = f'Commit {self.git_commit.short_id}'
commit_id: str = f'Commit {self.get_short_id()}'
if self.is_well_formatted():
return f'{commit_id} is well-formatted'
else:
......@@ -341,6 +347,12 @@ class GitlabCommit:
conjunction = ' and '
return f'{commit_id} {blank_line_comment}{conjunction}{overlong_line_comment}.'
def __eq__(self, other: "GitlabCommit") -> bool:
return self.get_id() == other.get_id()
def __ne__(self, other: "GitlabCommit") -> bool:
return not self.__eq__(other)
# git_commit fields:
# comments
# discussions
......@@ -407,7 +419,7 @@ class GitlabMilestone:
"""
return self.git_milestone.description
def get_created_at(self) -> date:
def get_start_date(self) -> date:
"""
:return: a date object representing the start date
"""
......@@ -416,6 +428,7 @@ class GitlabMilestone:
month = int(date_segments[1])
day = int(date_segments[2])
return date(year, month, day)
# return date.fromisoformat(date_segments) # TODO: requires Python 3.7; I'm using 3.7 - why can't I use this?
def get_due_date(self) -> date:
"""
......@@ -426,10 +439,17 @@ class GitlabMilestone:
month = int(date_segments[1])
day = int(date_segments[2])
return date(year, month, day)
# return date.fromisoformat(date_segments) # TODO: requires Python 3.7; I'm using 3.7 - why can't I use this?
def __repr__(self) -> str:
return self.get_title()
def __eq__(self, other: "GitlabMilestone") -> bool:
return self.git_milestone.id == other.git_milestone.id
def __ne__(self, other: "GitlabMilestone") -> bool:
return not self.__eq__(other)
# other git_milestone fields:
# id
# iid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment