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
394d410d
Commit
394d410d
authored
5 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Added option to check for proper commit message formatting
parent
fb41f6e9
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
+25
-0
25 additions, 0 deletions
api/gitlab_classes.py
with
25 additions
and
0 deletions
api/gitlab_classes.py
+
25
−
0
View file @
394d410d
from
datetime
import
datetime
from
functools
import
reduce
from
typing
import
ClassVar
,
Dict
,
Iterable
,
List
,
Optional
,
Set
,
Union
from
gitlab
import
Gitlab
,
MAINTAINER_ACCESS
...
...
@@ -229,6 +230,30 @@ class GitlabCommit:
deletions
+=
diff
[
'
-
'
]
return
max
(
insertions
,
deletions
)
@staticmethod
def
_number_of_lines_too_long
(
lines
,
subject_line_length
,
message_line_length
):
# noinspection PyUnusedLocal
lines_too_long
:
int
if
len
(
lines
)
==
1
:
lines_too_long
=
0
if
len
(
lines
[
0
])
<=
message_line_length
else
1
else
:
lines_too_long
=
0
if
len
(
lines
[
0
])
<=
subject_line_length
else
1
lines_too_long
+=
reduce
((
lambda
x
,
y
:
x
+
y
),
list
(
map
(
lambda
line
:
0
if
len
(
line
)
<=
message_line_length
else
1
,
lines
[
1
:])))
return
lines_too_long
@staticmethod
def
_has_blank_line_after_subject
(
lines
):
if
len
(
lines
)
==
1
:
return
True
else
:
return
lines
[
1
]
==
''
def
is_well_formatted
(
self
,
subject_line_length
=
72
,
message_line_length
=
72
)
->
bool
:
lines
:
List
[
str
]
=
self
.
get_message
().
rstrip
(
'
\n
'
).
split
(
'
\n
'
)
return
self
.
_number_of_lines_too_long
(
lines
,
subject_line_length
,
message_line_length
)
==
0
\
and
self
.
_has_blank_line_after_subject
(
lines
)
# git_commit fields:
# comments
# discussions
...
...
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