Christian Decker
4 years ago
2 changed files with 54 additions and 33 deletions
@ -0,0 +1,54 @@ |
|||
#!/usr/bin/env python3 |
|||
from sh import git, rm, mv |
|||
import re |
|||
import os |
|||
|
|||
rm = rm.bake("-rf") |
|||
grm = git.bake("rm", "--cached") |
|||
commit = git.bake("commit", "-am") |
|||
gclone = git.bake("clone", "--recursive") |
|||
gadd = git.bake("add") |
|||
# Read the gitmodules file |
|||
submodules = {} |
|||
|
|||
for l in git("submodule").split("\n"): |
|||
if " " not in l: |
|||
continue |
|||
h, d = l.split(" ") |
|||
h = h[1:] |
|||
submodules[d] = {"path": d, "hash": h, "name": None, "url": None} |
|||
|
|||
curr = None |
|||
name = None |
|||
r = re.compile(r"(submodule|path|url) [=]?[ ]?\"?([^\"]+)\"?") |
|||
for l in open(".gitmodules", "r"): |
|||
matches = r.search(l.strip()) |
|||
if not matches: |
|||
continue |
|||
if matches[1] == "submodule": |
|||
name = matches[2] |
|||
elif matches[1] == "path": |
|||
curr = matches[2] |
|||
submodules[curr]["name"] = name |
|||
elif matches[1] == "url": |
|||
submodules[curr]["url"] = matches[2] |
|||
|
|||
grm(".gitmodules") |
|||
for module in submodules.values(): |
|||
grm(module["path"]) |
|||
rm(module["path"]) |
|||
|
|||
commit("scripted: Remove submodules for materialization") |
|||
mv(".gitignore", ".gitignore.bak") |
|||
|
|||
for module in submodules.values(): |
|||
gclone(module["url"], module["path"]) |
|||
d = os.getcwd() |
|||
os.chdir(module["path"]) |
|||
git("checkout", module["hash"]) |
|||
os.chdir(d) |
|||
rm(f"{module['path']}/.git") |
|||
gadd(module["path"]) |
|||
|
|||
mv(".gitignore.bak", ".gitignore") |
|||
commit("scripted: Materialize submodules") |
@ -1,33 +0,0 @@ |
|||
git rm .gitmodules |
|||
git rm --cached external/jsmn external/libsodium external/libbacktrace external/libwally-core |
|||
rm -rf external/jsmn external/libsodium external/libbacktrace external/libwally-core external/gheap |
|||
|
|||
rm -rf .git/modules/external/jsmn .git/modules/external/libsodium .git/modules/external/libbacktrace .git/modules/external/libwally-core .git/modules/external/gheap |
|||
|
|||
git commit -am "scripted: Remove submodules for materialization" |
|||
|
|||
git clone --recursive https://github.com/valyala/gheap external/gheap/ |
|||
git clone --recursive https://github.com/zserge/jsmn external/jsmn |
|||
git clone --recursive https://github.com/ianlancetaylor/libbacktrace.git external/libbacktrace |
|||
git clone --recursive https://github.com/jedisct1/libsodium.git external/libsodium |
|||
git clone --recursive https://github.com/ElementsProject/libwally-core.git external/libwally-core |
|||
|
|||
(cd external/gheap; git checkout 67fc83bc953324f4759e52951921d730d7e65099) |
|||
(cd external/jsmn; git checkout 18e9fe42cbfe21d65076f5c77ae2be379ad1270f) |
|||
(cd external/libbacktrace; git checkout 5a99ff7fed66b8ea8f09c9805c138524a7035ece) |
|||
(cd external/libsodium; git checkout 675149b9b8b66ff44152553fb3ebf9858128363d) |
|||
(cd external/libwally-core; git checkout b8d7ea91049c3d5522768c77c8bfe4936cbabbd7) |
|||
|
|||
rm -rf external/jsmn/.git external/libsodium/.git/ external/libbacktrace/.git/ external/libwally-core/.git |
|||
|
|||
# Move gitignore out of the way so the following adds work |
|||
mv .gitignore .gitignore.bak |
|||
|
|||
git add external/jsmn |
|||
git add external/libsodium |
|||
git add external/libbacktrace |
|||
git add external/libwally-core |
|||
|
|||
mv .gitignore.bak .gitignore |
|||
|
|||
git commit -am "scripted: Materialize submodules" |
Loading…
Reference in new issue