- Set project visibility to internal.

- Have at least a master branch in solutions repo from which to fork
This commit is contained in:
Tim Schubert 2018-08-16 11:19:24 +02:00
parent d7a8440e11
commit 7b8e0461d3

View file

@ -39,7 +39,7 @@ def create_tag(project, tag, ref):
deadline deadline
""" """
print('Project %s. Creating tag %s' % (project.name, tag)) print('Project %s. Creating tag %s' % (project.path, tag))
project.tags.create({ project.tags.create({
'tag_name': tag, 'tag_name': tag,
@ -150,6 +150,7 @@ def setup_course(gl, group, students_csv, deploy_key):
'name': 'solutions', 'name': 'solutions',
'path': 'solutions', 'path': 'solutions',
'parent_id': group.id, 'parent_id': group.id,
'visibility': 'internal',
}) })
except gitlab.exceptions.GitlabCreateError as e: except gitlab.exceptions.GitlabCreateError as e:
log.info('Failed to create solutions group. %s' % e.error_message) log.info('Failed to create solutions group. %s' % e.error_message)
@ -162,7 +163,19 @@ def setup_course(gl, group, students_csv, deploy_key):
try: try:
reference_project = gl.projects.create({ reference_project = gl.projects.create({
'name': 'solutions', 'name': 'solutions',
'namespace_id': solution.id 'namespace_id': solution.id,
'visibility': 'internal',
})
reference_project.commits.create({
'branch': 'master',
'commit_message': 'Initial commit',
'actions': [
{
'action': 'create',
'file_path': 'README.md',
'content': 'Example solutions go here',
},
]
}) })
except gitlab.exceptions.GitlabCreateError as e: except gitlab.exceptions.GitlabCreateError as e:
log.info('Failed to setup group structure. %s' % e.error_message) log.info('Failed to setup group structure. %s' % e.error_message)
@ -198,7 +211,7 @@ def deadline(gl, args):
reference = gl.projects.get(args.reference, lazy=True) reference = gl.projects.get(args.reference, lazy=True)
for fork in reference.forks.list(): for fork in reference.forks.list():
project = gl.projects.get(fork.id, lazy=True) project = gl.projects.get(fork.id, lazy=False)
try: try:
create_tag(project, deadline_name, 'master') create_tag(project, deadline_name, 'master')
except gitlab.exceptions.GitlabCreateError as e: except gitlab.exceptions.GitlabCreateError as e:
@ -213,7 +226,6 @@ def plagiates(gl, args):
""" """
tag = args.tag_name tag = args.tag_name
try:
reference = gl.projects.get(args.reference, lazy=True) reference = gl.projects.get(args.reference, lazy=True)
try: try:
os.mkdir('solutions') os.mkdir('solutions')
@ -227,6 +239,8 @@ def plagiates(gl, args):
subprocess.run( subprocess.run(
['git', 'clone', '--branch', tag, project.ssh_url_to_repo, project.path_with_namespace]) ['git', 'clone', '--branch', tag, project.ssh_url_to_repo, project.path_with_namespace])
os.chdir('..') os.chdir('..')
except:
print(e.error_message)
subprocess.run( subprocess.run(
['java', '-jar', args.jplag_jar, '-s', 'solutions', '-p', 'java', '-r', 'results', '-bc', args.reference, '-l', 'java17']) ['java', '-jar', args.jplag_jar, '-s', 'solutions', '-p', 'java', '-r', 'results', '-bc', args.reference, '-l', 'java17'])
@ -236,7 +250,8 @@ def course(gl, args):
try: try:
group = gl.groups.create({ group = gl.groups.create({
'name': args.course, 'name': args.course,
'path': args.course 'path': args.course,
'visibility': 'internal',
}) })
log.info('Created group %s' % args.course) log.info('Created group %s' % args.course)
except gitlab.exceptions.GitlabCreateError as e: except gitlab.exceptions.GitlabCreateError as e: