I am logged in as root using gitlab-api with Python. On the server, I have a git repository which consists of my template ( example ) code. This template code is however not under Adminstrator, but under my own namespace ( teacher/template) . I want to distribute this template project to 25 students as an assignment i.e fork this template to 25 additional projects, but in a different namespace/group such as StudentsGroup/assignment1, StudentsGroup/assignment2... and soforth.
Can anyone tell me what is the best way to achieve it?
In the gitlab api, I have seen two possibilities:
First option:
Admin fork relation
Allows modification of the forked relationship between existing projects. Available only for admins. Create a forked from/to relation between existing projects.
POST /projects/:id/fork/:forked_from_id
Parameters:
id (required) - The ID of the project
forked_from_id: (required) - The ID of the project that was forked from
Second option:
Fork project
Forks a project into the user namespace of the authenticated user.
POST /projects/fork/:id
Parameters:
id (required) - The ID of the project to be forked
As of today 06, Sep, 2015, no solution is available. So, I found a workaround.
Begin a for loop:
Create empty Students/jobs_{count}.git in using the normal create project API
In the local disk, keep changing the remote origin in a script file, like git remote set-url origin git@server:Students/jobs_{count}.git
Push the files git push origin master
End of for loop
If anyone is interested in the script, you can ping me or will upload it later after removing the credentials.