Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
scripts
Commits
03571388
Commit
03571388
authored
Jul 30, 2020
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added equality methods to GitlabIssue, GitlabCommit, and GitlabMilestone
parent
1d9a3ded
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/gitlab_classes.py
+24
-4
24 additions, 4 deletions
api/gitlab_classes.py
with
24 additions
and
4 deletions
api/gitlab_classes.py
+
24
−
4
View file @
03571388
...
...
@@ -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
.
g
i
t_
commit
.
short_id
}
'
commit_id
:
str
=
f
'
Commit
{
self
.
g
e
t_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_d
at
e
(
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment