Commit c0448c18 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Ben Gamari
Browse files

gitlab-ci: Clone haddock from its upstream repository

This ensures that changes requiring haddock changes can be built under CI.
parent 9ea8dcea
...@@ -119,7 +119,7 @@ validate-x86_64-darwin: ...@@ -119,7 +119,7 @@ validate-x86_64-darwin:
LANG: "en_US.UTF-8" LANG: "en_US.UTF-8"
before_script: before_script:
- git clean -xdf && git submodule foreach git clean -xdf - git clean -xdf && git submodule foreach git clean -xdf
- python .gitlab/ - python3 .gitlab/
- git submodule sync --recursive - git submodule sync --recursive
- git submodule update --init --recursive - git submodule update --init --recursive
- git checkout .gitmodules - git checkout .gitmodules
#!/usr/bin/python #!/usr/bin/env python3
Fix submodule upstream URLs. This ensures that CI builds of GHC forks
clone their submodules from its usual location. Otherwise users would need to
fork all submodules before their CI builds would succeed.
from typing import List, Dict
from pathlib import Path
import re import re
x = open('.gitmodules').read() x = open('.gitmodules').read()
x = re.sub(r"url *= *\.\.", "url =", x) x = re.sub(r"url *= *\.\.", "url =", x)
open('.gitmodules', 'w').write(x) open('.gitmodules', 'w').write(x)
import subprocess
def get_configs(config_file: Path) -> Dict[str, str]:
args = ['git', 'config', '-f', config_file.as_posix(), '--list']
out = subprocess.check_output(args)
configs = {}
for line in out.decode('UTF-8').split('\n'):
if '=' in line:
k,v = line.split('=')
configs[k] = v
return configs
def set_config(config_file: Path, key: str, value: str) -> None:
args = ['git', 'config', '-f', config_file.as_posix(), '--replace', key, value]
upstreams = {
'utils/haddock': ''
modules_config = Path('.gitmodules')
def main():
for k,v in get_configs(modules_config).items():
match = re.match('submodule\.(.+)\.url', k)
if match is not None:
submod =
if submod in upstreams:
url = upstreams[submod]
url = re.sub('\.\.', '', v)
print('Using {submod} from {url}'.format(submod=submod, url=url))
set_config(modules_config, k, url)
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment