diff --git a/api/gitlab_classes.py b/api/gitlab_classes.py index 628d5ef9b05bc3702ccfd9cf29691793fa1456fe..b8f634ca6a7d66167a5ebbaf9a22a6e2de36349e 100644 --- a/api/gitlab_classes.py +++ b/api/gitlab_classes.py @@ -111,8 +111,8 @@ class GitlabIssue: """ return self.git_issue.description - @deprecated - def get_state(self) -> str: # TODO, delete after we're sure there are no uses + @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