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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CSCE 361
scripts
Commits
7bb51fc6
Commit
7bb51fc6
authored
4 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Refactored field names for consistency
parent
d67d9862
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/gitlab_classes.py
+22
-22
22 additions, 22 deletions
api/gitlab_classes.py
with
22 additions
and
22 deletions
api/gitlab_classes.py
+
22
−
22
View file @
7bb51fc6
...
...
@@ -208,35 +208,35 @@ class GitlabIssue:
class
GitlabCommit
:
git
lab
_commit
:
ProjectCommit
git_commit
:
ProjectCommit
# noinspection PyShadowingNames
def
__init__
(
self
,
commit
:
ProjectCommit
):
super
().
__init__
()
self
.
git
lab
_commit
=
commit
self
.
git_commit
=
commit
def
get_author
(
self
)
->
Dict
[
str
,
str
]:
return
{
'
name
'
:
self
.
git
lab
_commit
.
author_name
,
'
email
'
:
self
.
git
lab
_commit
.
author_email
}
return
{
'
name
'
:
self
.
git_commit
.
author_name
,
'
email
'
:
self
.
git_commit
.
author_email
}
def
get_timestamp
(
self
)
->
datetime
:
return
datetime
.
fromisoformat
(
self
.
git
lab
_commit
.
created_at
)
return
datetime
.
fromisoformat
(
self
.
git_commit
.
created_at
)
def
get_message
(
self
)
->
str
:
return
self
.
git
lab
_commit
.
message
return
self
.
git_commit
.
message
def
is_merge
(
self
)
->
bool
:
return
len
(
self
.
git
lab
_commit
.
parent_ids
)
>
1
return
len
(
self
.
git_commit
.
parent_ids
)
>
1
def
get_id
(
self
)
->
str
:
return
self
.
git
lab
_commit
.
id
return
self
.
git_commit
.
id
def
get_short_id
(
self
)
->
str
:
return
self
.
git
lab
_commit
.
short_id
return
self
.
git_commit
.
short_id
# noinspection PyShadowingNames
def
get_diffs
(
self
)
->
List
[
Dict
[
str
,
Union
[
str
,
int
]]]:
diffs
:
List
[
Dict
[
str
,
Union
[
str
,
int
]]]
=
[]
gitlab_diffs
:
List
[
Dict
[
str
,
str
]]
=
self
.
git
lab
_commit
.
diff
()
gitlab_diffs
:
List
[
Dict
[
str
,
str
]]
=
self
.
git_commit
.
diff
()
for
diff
in
gitlab_diffs
:
diffs
.
append
({
'
file
'
:
diff
[
'
new_path
'
],
'
text
'
:
diff
[
'
diff
'
],
'
+
'
:
diff
[
'
diff
'
].
count
(
'
\n
+
'
),
'
-
'
:
diff
[
'
diff
'
].
count
(
'
\n
-
'
)})
...
...
@@ -306,7 +306,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
lab
_commit
.
short_id
}
'
commit_id
:
str
=
f
'
Commit
{
self
.
git_commit
.
short_id
}
'
if
self
.
is_well_formatted
():
return
f
'
{
commit_id
}
is well-formatted
'
else
:
...
...
@@ -349,17 +349,17 @@ class GitlabCommit:
class
GitlabMilestone
:
git
lab
_milestone
:
ProjectMilestone
git_milestone
:
ProjectMilestone
def
__init__
(
self
,
milestone
:
ProjectMilestone
):
super
().
__init__
()
self
.
git
lab
_milestone
=
milestone
self
.
git_milestone
=
milestone
def
get_issues
(
self
)
->
List
[
GitlabIssue
]:
"""
:return: List of Issue objects representing project
'
s issues
"""
gitlab_issues
:
Iterable
[
Issue
]
=
self
.
git
lab
_milestone
.
issues
()
gitlab_issues
:
Iterable
[
Issue
]
=
self
.
git_milestone
.
issues
()
issues
:
List
[
GitlabIssue
]
=
[]
for
issue
in
gitlab_issues
:
issues
.
append
(
GitlabIssue
(
issue
))
...
...
@@ -369,35 +369,35 @@ class GitlabMilestone:
"""
:return: True if the milestone is active; False if the milestone is closed
"""
return
self
.
git
lab
_milestone
.
state
==
'
active
'
return
self
.
git_milestone
.
state
==
'
active
'
def
is_closed
(
self
)
->
bool
:
"""
:return: True if the milestone is closed; False if the milestone is active
"""
return
self
.
git
lab
_milestone
.
state
==
'
closed
'
return
self
.
git_milestone
.
state
==
'
closed
'
def
close
(
self
)
->
None
:
self
.
git
lab
_milestone
.
state_event
=
'
close
'
self
.
git
lab
_milestone
.
save
()
self
.
git_milestone
.
state_event
=
'
close
'
self
.
git_milestone
.
save
()
def
get_title
(
self
)
->
str
:
"""
:return: The milestone
'
s title
"""
return
self
.
git
lab
_milestone
.
title
return
self
.
git_milestone
.
title
def
get_description
(
self
)
->
str
:
"""
:return: The milestone
'
s description
"""
return
self
.
git
lab
_milestone
.
description
return
self
.
git_milestone
.
description
def
get_created_at
(
self
)
->
date
:
"""
:return: a date object representing the start date
"""
date_segments
:
List
[
str
]
=
self
.
git
lab
_milestone
.
start_date
.
split
(
'
-
'
)
date_segments
:
List
[
str
]
=
self
.
git_milestone
.
start_date
.
split
(
'
-
'
)
year
=
int
(
date_segments
[
0
])
month
=
int
(
date_segments
[
1
])
day
=
int
(
date_segments
[
2
])
...
...
@@ -407,7 +407,7 @@ class GitlabMilestone:
"""
:return: a date object representing the due date
"""
date_segments
:
List
[
str
]
=
self
.
git
lab
_milestone
.
due_date
.
split
(
'
-
'
)
date_segments
:
List
[
str
]
=
self
.
git_milestone
.
due_date
.
split
(
'
-
'
)
year
=
int
(
date_segments
[
0
])
month
=
int
(
date_segments
[
1
])
day
=
int
(
date_segments
[
2
])
...
...
@@ -416,7 +416,7 @@ class GitlabMilestone:
def
__repr__
(
self
)
->
str
:
return
self
.
get_title
()
# other git
lab
_milestone fields:
# other git_milestone fields:
# id
# iid
# project_id
...
...
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