-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (28 loc) · 917 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gitlab
import subprocess
import os
gl = gitlab.Gitlab(url='', private_token='')
rootdir = 'repo'
depth = 1
group_id = <add your group_id>
def download_repo():
group = gl.groups.get(group_id)
subprocess.run('rm -rf repo/*', shell=True)
os.chdir("repo")
print(os.getcwd())
for project in group.projects.list(iterator=True):
print(project.name + " " + project.ssh_url_to_repo)
subprocess.call(['git', 'clone', project.ssh_url_to_repo])
os.chdir("..")
def upload_repo():
for subdir, dirs, files in os.walk(rootdir):
if subdir[len(rootdir):].count(os.sep) == depth:
# print(subdir)
os.chdir(subdir)
print(os.getcwd())
subprocess.run('git revert HEAD~0', shell=True)
subprocess.run('git push', shell=True)
os.chdir('../..')
print(os.getcwd())
download_repo()
upload_repo()