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
2849e2fd
Commit
2849e2fd
authored
4 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Commit format sniffer now reports across all branches
parent
02c5b870
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/gitlab_classes.py
+9
-0
9 additions, 0 deletions
api/gitlab_classes.py
commit_format_info.py
+37
-22
37 additions, 22 deletions
commit_format_info.py
with
46 additions
and
22 deletions
api/gitlab_classes.py
+
9
−
0
View file @
2849e2fd
...
...
@@ -250,6 +250,9 @@ class GitlabCommit:
def
is_merge
(
self
)
->
bool
:
return
len
(
self
.
git_commit
.
parent_ids
)
>
1
def
is_revert
(
self
)
->
bool
:
return
self
.
get_message
().
startswith
(
'
Revert
'
)
def
get_id
(
self
)
->
str
:
return
self
.
git_commit
.
id
...
...
@@ -659,6 +662,12 @@ class GitlabProject:
commits
.
append
(
GitlabCommit
(
commit
))
return
commits
def
get_branch_names
(
self
)
->
List
[
str
]:
branches
=
self
.
git_project
.
branches
.
list
()
branch_names
:
List
[
str
]
=
list
(
map
(
lambda
b
:
b
.
name
,
branches
))
return
branch_names
def
get_labels
(
self
)
->
Set
[
str
]:
"""
:return: set of label names
...
...
This diff is collapsed.
Click to expand it.
commit_format_info.py
+
37
−
22
View file @
2849e2fd
from
api.gitlab_classes
import
*
from
course
import
Course
if
__name__
==
'
__main__
'
:
projects
=
GitlabProject
.
get_projects_by_group
(
Course
.
gitlab_namespace
)
projects
=
list
(
filter
(
lambda
p
:
p
.
get_name
().
startswith
(
'
30pair
'
),
projects
))
projects
.
sort
(
key
=
lambda
p
:
p
.
get_name
())
for
project
in
projects
:
commits
=
project
.
get_commits
()
print
(
f
'
\n\n
. >>>>
{
project
}
<<<<
'
)
print
(
f
'
{
len
(
commits
)
}
commits on the master branch
'
)
# noinspection PyShadowingNames
def
judge_commits
(
commits
:
List
[
GitlabCommit
]):
merges
=
0
reverts
=
0
well_formatted_commits
=
0
...
...
@@ -16,14 +11,34 @@ if __name__ == '__main__':
for
commit
in
commits
:
if
commit
.
is_merge
():
merges
+=
1
elif
commit
.
get_message
().
startswith
(
'
R
evert
'
):
elif
commit
.
is_r
evert
(
):
reverts
+=
1
elif
commit
.
is_well_formatted
():
well_formatted_commits
+=
1
else
:
malformatted_commits
.
append
(
commit
)
print
(
f
'
{
merges
}
merges,
{
reverts
}
reverts,
{
well_formatted_commits
}
well-formatted commits,
'
f
'
\t\t
{
merges
}
merges,
{
reverts
}
reverts,
{
well_formatted_commits
}
well-formatted commits,
'
f
'
and
{
len
(
malformatted_commits
)
}
malformatted commits
'
)
for
commit
in
malformatted_commits
:
print
(
f
'
{
commit
.
detail_formatting_problems
()
}
(
{
commit
.
get_author
()
}
)
'
)
print
(
f
'
\t\t
{
commit
.
get_timestamp
()
}
{
commit
.
detail_formatting_problems
()
}
(
{
commit
.
get_author
()[
"
name
"
]
}
)
'
)
if
__name__
==
'
__main__
'
:
projects
=
GitlabProject
.
get_projects_by_group
(
Course
.
gitlab_namespace
)
# projects = list(filter(lambda p: p.get_name().startswith('30pair'), projects))
projects
=
list
(
filter
(
lambda
p
:
p
.
get_name
().
startswith
(
'
36team
'
),
projects
))
# TODO: soft-code prefix
projects
.
sort
(
key
=
lambda
p
:
p
.
get_name
())
for
project
in
projects
:
print
(
f
'
\n\n\t
>>>>
{
project
}
<<<<
'
)
master_branch_commits
=
project
.
get_commits
()
print
(
f
'
{
len
(
master_branch_commits
)
}
commits on the master branch
'
)
all_branches_commits
:
Set
[
GitlabCommit
]
=
set
()
for
branch
in
project
.
get_branch_names
():
for
commit
in
project
.
get_commits
(
branch
):
all_branches_commits
.
add
(
commit
)
print
(
f
'
{
len
(
all_branches_commits
)
}
commits among all branches
'
)
print
(
'
\t
On the master branch:
'
)
judge_commits
(
master_branch_commits
)
print
(
'
\t
On all other branches:
'
)
judge_commits
(
list
(
sorted
(
all_branches_commits
-
set
(
master_branch_commits
),
key
=
lambda
c
:
c
.
get_timestamp
())))
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