-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit2git.py
executable file
·120 lines (115 loc) · 3.23 KB
/
git2git.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from pathlib import Path
from git import Repo, GitCommandError
for name, source_git, target_git in [
# (
# "fuchsia",
# "https://fuchsia.googlesource.com/fuchsia",
# "[email protected]:live-clones/fuchsia.git",
# ),
(
"beautifulsoup",
"https://git.launchpad.net/beautifulsoup",
"[email protected]:live-clones/beautifulsoup.git",
),
(
"nala",
"https://gitlab.com/volian/nala.git",
"[email protected]:live-clones/nala.git",
),
(
"apt",
"https://salsa.debian.org/apt-team/apt",
"[email protected]:live-clones/apt.git",
),
(
"eigen",
"https://gitlab.com/libeigen/eigen.git",
"[email protected]:live-clones/eigen.git",
),
(
"dolfin",
"https://bitbucket.org/fenics-project/dolfin.git",
"[email protected]:live-clones/dolfin.git",
),
# (
# "recalbox",
# "https://gitlab.com/recalbox/recalbox.git",
# "[email protected]:live-clones/recalbox.git",
# ),
(
"gmsh",
"https://gitlab.onelab.info/gmsh/gmsh.git",
"[email protected]:live-clones/gmsh.git",
),
(
"linitian",
"https://salsa.debian.org/lintian/lintian.git",
"[email protected]:live-clones/lintian.git",
),
(
"pybtex",
"https://bitbucket.org/pybtex-devs/pybtex.git",
"[email protected]:live-clones/pybtex.git",
),
(
"xdmf",
"https://gitlab.kitware.com/xdmf/xdmf.git",
"[email protected]:live-clones/xdmf.git",
),
(
"chktex",
"https://git.savannah.gnu.org/git/chktex.git",
"[email protected]:live-clones/chktex.git",
),
(
"blaze",
"https://bitbucket.org/blaze-lib/blaze.git",
"[email protected]:live-clones/blaze.git",
),
(
"scotch",
"https://gitlab.inria.fr/scotch/scotch.git",
"[email protected]:live-clones/scotch.git",
),
# (
# # Before pushing, we have to remove a file with
# # ```
# # bfg --delete-files rtttest2.rttt
# # ```
# # since it's larger than 100 MB (GitHub won't allow it).
# "moab",
# "https://bitbucket.org/fathomteam/moab.git",
# "[email protected]:live-clones/moab.git",
# ),
(
"wlroots",
"https://gitlab.freedesktop.org/wlroots/wlroots.git",
"[email protected]:live-clones/wlroots.git",
),
]:
print(f"{name}...")
# replace / and : by - in the first argument $1
directory = Path.home() / "tmp" / source_git.replace("/", "-").replace(":", "-")
if directory.exists():
repo = Repo(directory)
else:
# It's currently not possible to clone with --mirror (clone all
# branches). See <https://stackoverflow.com/q/42132676/353337>.
repo = Repo.clone_from(
source_git,
directory,
bare=True,
mirror=True,
recursive=True,
)
repo.create_remote("github", url=target_git)
# pull from source
print(" Fetch...")
repo.remotes["origin"].fetch()
# push to GitHub
print(" Push...")
try:
repo.remotes["github"].push(mirror=True)
except GitCommandError as e:
print(e)
pass