Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
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
Creak
funkwhale
Commits
310089d8
Commit
310089d8
authored
3 years ago
by
Georg Krause
Browse files
Options
Downloads
Patches
Plain Diff
Get Committers list from git & update contributors script
parent
6136f866
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CONTRIBUTING.rst
+2
-1
2 additions, 1 deletion
CONTRIBUTING.rst
scripts/get-contributions-stats.py
+79
-100
79 additions, 100 deletions
scripts/get-contributions-stats.py
with
81 additions
and
101 deletions
CONTRIBUTING.rst
+
2
−
1
View file @
310089d8
...
@@ -759,7 +759,8 @@ To make a new 3.4 release::
...
@@ -759,7 +759,8 @@ To make a new 3.4 release::
# polish changelog
# polish changelog
# - update the date
# - update the date
# - look for typos
# - look for typos
# - add list of contributors via `python3 scripts/get-contributions-stats.py develop $PREVIOUS_RELEASE`
# - add list of contributors via `python3 scripts/get-contributions-stats.py $NEXT_RELEASE`
git log $PREVIOUS_RELEASE.. --format="%aN" --reverse | sort | uniq -u # Get all commit authors since last release
nano CHANGELOG
nano CHANGELOG
# Set the `__version__` variable to $NEXT_RELEASE
# Set the `__version__` variable to $NEXT_RELEASE
...
...
This diff is collapsed.
Click to expand it.
scripts/get-contributions-stats.py
+
79
−
100
View file @
310089d8
...
@@ -8,121 +8,100 @@ WEBLATE_URL = "https://translate.funkwhale.audio"
...
@@ -8,121 +8,100 @@ WEBLATE_URL = "https://translate.funkwhale.audio"
WEBLATE_COMPONENT_ID
=
"
funkwhale/front
"
WEBLATE_COMPONENT_ID
=
"
funkwhale/front
"
def
get_commits
(
ref_name
,
since
):
def
get_issues
(
next_release
):
url
=
GITLAB_URL
+
"
/api/v4/projects/{}/repository/commits
"
.
format
(
url
=
GITLAB_URL
+
"
/api/v4/issues
"
GITLAB_PROJECT_ID
# TODO assumes we have less than 100 issues per Milestone
response
=
requests
.
get
(
url
,
params
=
{
"
per_page
"
:
100
,
"
milestone
"
:
next_release
,
"
scope
"
:
"
all
"
},
headers
=
{
"
PRIVATE-TOKEN
"
:
os
.
environ
[
"
PRIVATE_TOKEN
"
]},
)
)
while
url
:
response
.
raise_for_status
()
response
=
requests
.
get
(
url
,
params
=
{
"
since
"
:
since
,
"
ref_name
"
:
ref_name
,
"
per_page
"
:
100
}
)
response
.
raise_for_status
()
yield
from
response
.
json
()
return
response
.
json
()
if
"
next
"
in
response
.
links
:
url
=
response
.
links
[
"
next
"
][
"
url
"
]
else
:
url
=
None
def
get_merge_requests
(
next_release
):
url
=
GITLAB_URL
+
"
/api/v4/merge_requests
"
# TODO assumes we have less than 100 issues per Milestone
response
=
requests
.
get
(
url
,
params
=
{
"
per_page
"
:
100
,
"
milestone
"
:
next_release
,
"
scope
"
:
"
all
"
},
headers
=
{
"
PRIVATE-TOKEN
"
:
os
.
environ
[
"
PRIVATE_TOKEN
"
]},
)
response
.
raise_for_status
()
def
get_commit_stats
(
commits
):
return
response
.
json
()
stats
=
{
"
total
"
:
0
,
"
commiters
"
:
{}}
for
commit
in
commits
:
if
commit
[
"
message
"
].
startswith
(
"
Merge branch
"
):
continue
stats
[
"
total
"
]
+=
1
try
:
stats
[
"
commiters
"
][
commit
[
"
author_name
"
]]
+=
1
except
KeyError
:
stats
[
"
commiters
"
][
commit
[
"
author_name
"
]]
=
1
return
stats
def
get_participants
(
project_id
,
issue_iid
,
object_type
=
"
issues
"
):
if
object_type
not
in
[
"
issues
"
,
"
merge_requests
"
]:
raise
ValueError
(
"
object_type needs to be `issues` or `merge_requests`
"
)
url
=
GITLAB_URL
+
"
/api/v4/projects/{}/{}/{}/participants
"
.
format
(
project_id
,
object_type
,
issue_iid
)
def
get_tag_date
(
ref
):
response
=
requests
.
get
(
url
=
GITLAB_URL
+
"
/api/v4/projects/{}/repository/tags/{}
"
.
format
(
url
,
GITLAB_PROJECT_ID
,
ref
params
=
{
"
per_page
"
:
100
},
headers
=
{
"
PRIVATE-TOKEN
"
:
os
.
environ
[
"
PRIVATE_TOKEN
"
]},
)
)
response
=
requests
.
get
(
url
)
response
.
raise_for_status
()
data
=
response
.
json
()
return
data
[
"
commit
"
][
"
committed_date
"
]
def
get_translations
(
since
):
url
=
WEBLATE_URL
+
"
/api/components/{}/changes/
"
.
format
(
WEBLATE_COMPONENT_ID
)
while
url
:
response
=
requests
.
get
(
url
)
response
.
raise_for_status
()
if
"
next
"
in
response
.
json
():
url
=
response
.
json
()[
"
next
"
]
else
:
url
=
None
for
t
in
response
.
json
()[
"
results
"
]:
if
t
[
"
timestamp
"
]
<
since
:
url
=
None
break
yield
t
def
get_translations_stats
(
translations
):
stats
=
{
"
total
"
:
0
,
"
translators
"
:
{}}
for
translation
in
translations
:
if
not
translation
[
"
author
"
]:
continue
print
(
"
translation
"
,
translation
[
"
action_name
"
])
continue
stats
[
"
total
"
]
+=
1
try
:
stats
[
"
translators
"
][
translation
[
"
author
"
]]
+=
1
except
KeyError
:
stats
[
"
translators
"
][
translation
[
"
author
"
]]
=
1
return
stats
def
get_group_usernames
(
group
):
url
=
GITLAB_URL
+
"
/api/v4/groups/{}/members
"
.
format
(
group
)
response
=
requests
.
get
(
url
,
headers
=
{
"
PRIVATE-TOKEN
"
:
os
.
environ
[
"
PRIVATE_TOKEN
"
]})
response
.
raise_for_status
()
response
.
raise_for_status
()
data
=
response
.
json
()
return
[
r
[
"
name
"
]
for
r
in
data
]
participants
=
[]
for
participant
in
response
.
json
():
participants
.
append
(
participant
[
"
name
"
])
return
participants
def
clear_list
(
inList
):
outList
=
list
(
dict
.
fromkeys
(
inList
))
try
:
outList
.
remove
(
"
funkwhale-bot
"
)
except
:
pass
try
:
outList
.
remove
(
"
weblate (bot)
"
)
except
:
pass
outList
.
sort
()
return
outList
def
main
():
def
main
():
if
"
PRIVATE_TOKEN
"
not
in
os
.
environ
:
print
(
"
Please configure an Gitlab Access token in $PRIVATE_TOKEN
"
)
return
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
ref_name
"
)
parser
.
add_argument
(
"
next_tag
"
)
parser
.
add_argument
(
"
last_tag
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
since
=
get_tag_date
(
args
.
last_tag
)
issues
=
get_issues
(
args
.
next_tag
)
commits
=
get_commits
(
args
.
ref_name
,
since
)
mrs
=
get_merge_requests
(
args
.
next_tag
)
commits_stats
=
get_commit_stats
(
commits
)
groups
=
[(
588
,
"
funkwhale/reviewers-python
"
),
(
589
,
"
funkwhale/reviewers-front
"
)]
print
(
"
\n
Contributors to our Issues:
\n
"
)
reviewers
=
[]
issue_participants
=
[]
for
id
,
_
in
groups
:
reviewers
+=
get_group_usernames
(
id
)
for
issue
in
issues
:
print
(
"
\n
Reviewers:
\n
"
)
participants
=
get_participants
(
issue
[
"
project_id
"
],
issue
[
"
iid
"
])
for
reviewer
in
reviewers
:
issue_participants
.
extend
(
participants
)
print
(
reviewer
)
commiter_names
=
commits_stats
[
"
commiters
"
].
keys
()
issue_participants
=
clear_list
(
issue_participants
)
print
(
"
\n
Commiters:
\n
"
)
for
contributor
in
issue_participants
:
for
commiter
in
sorted
(
commits_stats
[
"
commiters
"
].
keys
(),
key
=
lambda
v
:
v
.
upper
()):
print
(
contributor
)
print
(
commiter
)
translations
=
get_translations
(
since
)
print
(
"
\n
Contributors to our Merge Requests:
\n
"
)
translations_stats
=
get_translations_stats
(
translations
)
mr_participants
=
[]
translators_ids
=
sorted
(
translations_stats
[
"
translators
"
].
keys
())
# There is no way to query user/author info via weblate API and we need the names…
for
mr
in
mrs
:
print
(
participants
=
get_participants
(
mr
[
"
project_id
"
],
mr
[
"
iid
"
],
"
merge_requests
"
)
"
\n
Execute the following SQL query on the weblate server to get the translators names:
"
mr_participants
.
extend
(
participants
)
)
print
(
"
$ weblate dbshell
"
)
mr_participants
=
clear_list
(
mr_participants
)
print
(
for
contributor
in
mr_participants
:
"
SELECT full_name FROM weblate_auth_user WHERE id in ({});
"
.
format
(
print
(
contributor
)
"
,
"
.
join
([
str
(
i
)
for
i
in
translators_ids
])
)
return
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
...
...
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