Commit 53e28db6 authored by Reto Gerber's avatar Reto Gerber
Browse files

update and add checks

parent 598073a3
Pipeline #81530 failed with stage
in 36 seconds
......@@ -26,7 +26,8 @@ data.frame(name=res_ls$username,
success_count=res_ls$success_count,
failed_count=res_ls$failed_count,
skipped_count=res_ls$skipped_count,
error_count=res_ls$error_count)
error_count=res_ls$error_count) %>%
knitr::kable()
```
```{r, results='asis'}
......
import gitlab
import sys
# access token
tok = sys.argv[1]
gl = gitlab.Gitlab('https://git.math.uzh.ch', private_token=tok, per_page=100)
gl = gitlab.Gitlab('https://gitlab.uzh.ch', private_token=tok, per_page=100)
username = "retogerber93"
user = gl.users.list(username=username)[0]
# namespace = gl.namespaces.list(search='open_science_course')[0]
namespace = gl.namespaces.list(search='Topic_1')[0]
namespace.attributes["full_path"] == 'open_science_course/topic_1'
teacher_ids = [gl.users.list(username='retogerber')[0],gl.users.list(username='eva.furrer')[0]]
project = gl.projects.create({'name': username,
'description': 'API test repo',
'shared_runners_enabled': True,
'namespace_id': namespace.id,
'visibility': 'private'})
project.name
member = project.members.create({'user_id': user.id, 'access_level': gitlab.MAINTAINER_ACCESS})
pusers = project.members.list()
pusers
gl.users.get(pusers[0].id).username
# gl.users.get(pusers[1].id).username
# member.access_level = gitlab.OWNER_ACCESS
# member.save()
data = {
'branch': 'master',
'commit_message': 'Prepare for CI/CD',
'actions': [
{
'action': 'create',
'file_path': '.gitlab-ci.yml',
'content': open('.gitlab-ci.yml').read(),
},{
'action': 'create',
'file_path': 'DESCRIPTION',
'content': open('DESCRIPTION').read(),
}
]
}
commit = project.commits.create(data)
project.delete()
users = gl.users.list()
user = gl.users.list(username='retogerber93')[0]
users = gl.users.list(search='reto')
# fork
fork = project.forks.create({})
forks = project.forks.list()
f = project.files.list()
items = project.repository_tree()
items
import gitlab
import sys
from itertools import compress
import numpy as np
import csv
expected_usernames = ["retogerber93","retogerber"]
# access token
tok = sys.argv[1]
gl = gitlab.Gitlab('https://gitlab.uzh.ch', private_token=tok, per_page=100)
project.name_with_namespace
project=gl.projects.list(search='Basics_of_Open_Science',owned=True)[0]
project.name_with_namespace
commits = project.commits.list()
commits[0].attributes
names_of_committers = [c.committer_name for c in commits]
names_of_committers
usernames_of_committers = []
for i in range(len(commits)):
potusers = gl.users.list(search=commits[i].committer_name)
potusers_names = [ n.username for n in potusers]
in_expected_usernames = [n in expected_usernames for n in potusers_names]
tmpls = list(compress(potusers_names,in_expected_usernames))
if len(tmpls)>0:
usernames_of_committers.append(tmpls[0])
else:
usernames_of_committers.append("")
usernames_of_committers
csv_ls = []
for i in range(len(commits)):
csv_ls.append([commits[i].short_id,commits[i].committer_name, usernames_of_committers[i]])
csv_colnames = ["commit_id","name","username"]
with open('output/commits_history.csv', 'w') as f:
write = csv.writer(f)
write.writerow(csv_colnames)
write.writerows(csv_ls)
uq_com_usernames = list(np.unique(usernames_of_committers))
uq_com_usernames_bool = [ u in uq_com_usernames for u in expected_usernames]
csv_ls = [[uq_com_usernames[i],uq_com_usernames_bool[i]] for i in range(len(uq_com_usernames))]
csv_colnames = ["username","has_committed"]
with open('output/username_list_commits.csv', 'w') as f:
write = csv.writer(f)
write.writerow(csv_colnames)
write.writerows(csv_ls)
uq_com_usernames = list(np.unique(names_of_committers))
uq_com_usernames_bool = [ u in uq_com_usernames for u in expected_usernames]
csv_ls = [[uq_com_usernames[i],uq_com_usernames_bool[i]] for i in range(len(uq_com_usernames))]
csv_colnames = ["username","has_committed"]
with open('output/name_list_commits.csv', 'w') as f:
write = csv.writer(f)
write.writerow(csv_colnames)
write.writerows(csv_ls)
# values, counts = np.unique(usernames_of_committers, return_counts=True)
# {a:b for a,b in zip(values, counts)}
......@@ -11,7 +11,7 @@ tok = sys.argv[1]
sls = sys.argv[2]
searched_members = sls.replace(" ","").split(',')
gl = gitlab.Gitlab('http://gitlab.uzh.ch', private_token=tok, per_page=100)
gl = gitlab.Gitlab('https://gitlab.uzh.ch', private_token=tok, per_page=100)
projects = gl.projects.list(visibility=["private"], all=True)
# get all project in which members specified in 'searched_members' are
......
......@@ -38,3 +38,4 @@ for(i in seq_along(resp2$projects$id)){
}
saveRDS(res_ls, here::here("output","all_test_results.rds"))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment