Teo Camarasu pushed to branch wip/T25262 at Glasgow Haskell Compiler / GHC

Commits:

9 changed files:

Changes:

  • libraries/addupstreams.py
    1
    +#!/usr/bin/env python3
    
    2
    +
    
    3
    +from pathlib import Path
    
    4
    +import subprocess
    
    5
    +import logging
    
    6
    +import re
    
    7
    +
    
    8
    +logging.basicConfig(level=logging.INFO)
    
    9
    +
    
    10
    +IGNORE = 1 # ignore submodule
    
    11
    +GITHUB_HASKELL = 2 # in the haskell github org
    
    12
    +ORIGIN = 3 # upstream remote == origin remote
    
    13
    +
    
    14
    +def github(owner: str, name: str) -> str:
    
    15
    +    return f'https://github.com/{owner}/{name}'
    
    16
    +
    
    17
    +def github_haskell(name: str) -> str:
    
    18
    +    return github('haskell', name)
    
    19
    +
    
    20
    +def gitlab_ssh(owner: str, name: str) -> str:
    
    21
    +    return f'git@gitlab.haskell.org:{owner}/{name}'
    
    22
    +
    
    23
    +upstreams = {
    
    24
    +    '.arc-linters/arcanist-external-json-linter': IGNORE,
    
    25
    +    'libffi-tarballs': IGNORE,
    
    26
    +    'libraries/array': GITHUB_HASKELL,
    
    27
    +    'libraries/binary': GITHUB_HASKELL,
    
    28
    +    'libraries/bytestring': GITHUB_HASKELL,
    
    29
    +    'libraries/Cabal': GITHUB_HASKELL,
    
    30
    +    'libraries/containers': GITHUB_HASKELL,
    
    31
    +    'libraries/deepseq': GITHUB_HASKELL,
    
    32
    +    'libraries/directory': GITHUB_HASKELL,
    
    33
    +    'libraries/file-io': GITHUB_HASKELL,
    
    34
    +    'libraries/filepath': GITHUB_HASKELL,
    
    35
    +    'libraries/ghc-bignum/gmp/gmp-tarballs': ORIGIN,
    
    36
    +    'libraries/ghc-internal/gmp/gmp-tarballs': ORIGIN,
    
    37
    +    'libraries/haskeline': GITHUB_HASKELL,
    
    38
    +    'libraries/hpc': ORIGIN,
    
    39
    +    'libraries/integer-gmp/gmp/gmp-tarballs': ORIGIN,
    
    40
    +    'libraries/mtl': GITHUB_HASKELL,
    
    41
    +    'libraries/os-string': GITHUB_HASKELL,
    
    42
    +    'libraries/parallel': GITHUB_HASKELL,
    
    43
    +    'libraries/parsec': GITHUB_HASKELL,
    
    44
    +    'libraries/pretty': GITHUB_HASKELL,
    
    45
    +    'libraries/primitive': GITHUB_HASKELL,
    
    46
    +    'libraries/process': GITHUB_HASKELL,
    
    47
    +    'libraries/semaphore-compat': ORIGIN,
    
    48
    +    'libraries/stm': GITHUB_HASKELL,
    
    49
    +    'libraries/terminfo': GITHUB_HASKELL,
    
    50
    +    'libraries/text': GITHUB_HASKELL,
    
    51
    +    'libraries/time': GITHUB_HASKELL,
    
    52
    +    'libraries/transformers': IGNORE, # darcs mirror
    
    53
    +    'libraries/unix': GITHUB_HASKELL,
    
    54
    +    'libraries/Win32': GITHUB_HASKELL,
    
    55
    +    'nofib': 'https://gitlab.haskell.org/ghc/nofib',
    
    56
    +    'utils/hpc': GITHUB_HASKELL,
    
    57
    +    'utils/haddock': GITHUB_HASKELL,
    
    58
    +}
    
    59
    +
    
    60
    +all_submods = [
    
    61
    +    line.split()[1]
    
    62
    +    for line in subprocess.check_output(['git', 'submodule'], encoding='UTF-8').split('\n')
    
    63
    +    if len(line.split()) > 0
    
    64
    +]
    
    65
    +
    
    66
    +packages = {
    
    67
    +    line.split()[0]: line.split()[3]
    
    68
    +    for line in open('packages').read().split('\n')
    
    69
    +    if not line.startswith('#')
    
    70
    +    if len(line.split()) == 4
    
    71
    +    if line.split()[3] != '-'
    
    72
    +}
    
    73
    +
    
    74
    +def get_remote_url(submod: str, remote: str):
    
    75
    +    p = subprocess.run(['git', '-C', submod, 'remote', 'get-url', remote],
    
    76
    +                       encoding='UTF-8',
    
    77
    +                       stdout=subprocess.PIPE,
    
    78
    +                       stderr=subprocess.DEVNULL)
    
    79
    +    if p.returncode == 0:
    
    80
    +        return p.stdout
    
    81
    +    else:
    
    82
    +        return None
    
    83
    +
    
    84
    +def add_remote(submod: str, remote: str, url: str):
    
    85
    +    old_url = get_remote_url(submod, remote)
    
    86
    +    if old_url is None:
    
    87
    +        logging.info(f'{submod}: adding remote {remote} = {url}')
    
    88
    +        subprocess.call(['git', '-C', submod, 'remote', 'add', remote, url])
    
    89
    +    elif old_url == url:
    
    90
    +        return
    
    91
    +    else:
    
    92
    +        logging.info(f'{submod}: updating remote {remote} = {url}')
    
    93
    +        subprocess.call(['git', '-C', submod, 'remote', 'set-url', remote, url])
    
    94
    +
    
    95
    +    #update_remote(submod, remote)
    
    96
    +
    
    97
    +def update_remote(submod: str, remote: str):
    
    98
    +    subprocess.check_call(['git', '-C', submod, 'remote', 'update', remote])
    
    99
    +
    
    100
    +def main():
    
    101
    +    for submod in all_submods:
    
    102
    +        print(submod)
    
    103
    +        upstream = None
    
    104
    +        if submod in upstreams:
    
    105
    +            upstream = upstreams[submod]
    
    106
    +        elif submod in packages:
    
    107
    +            upstream = packages[submod]
    
    108
    +
    
    109
    +        if upstream == ORIGIN:
    
    110
    +            upstream = subprocess.check_output(['git', '-C', submod, 'remote', 'get-url', 'origin'], encoding='UTF-8').strip()
    
    111
    +        elif upstream == GITHUB_HASKELL:
    
    112
    +            upstream = github_haskell(Path(submod).name)
    
    113
    +        elif upstream == IGNORE:
    
    114
    +            continue
    
    115
    +
    
    116
    +        if upstream is None:
    
    117
    +            print(f'Unknown upstream for {submod}')
    
    118
    +            raise ValueError('unknown upstream')
    
    119
    +        else:
    
    120
    +            print(f'Upstream of {submod} is {upstream}')
    
    121
    +            add_remote(submod, 'upstream', upstream)
    
    122
    +
    
    123
    +        origin = get_remote_url(submod, 'origin')
    
    124
    +        m = re.match('https://gitlab.haskell.org/(.*)', origin)
    
    125
    +        if m is not None:
    
    126
    +            push = f'git@gitlab.haskell.org:{m.group(1)}'
    
    127
    +            print(f'origin-push of {submod} is {push}')
    
    128
    +            add_remote(submod, 'origin-push', push)
    
    129
    +
    
    130
    +        name = Path(submod).name
    
    131
    +        add_remote(submod, 'teo', f'git@github.com:TeofilC/{name}')
    
    132
    +
    
    133
    +if __name__ == '__main__':
    
    134
    +    main()
    
    135
    +

  • libraries/bytestring
    1
    -Subproject commit d984ad00644c0157bad04900434b9d36f23633c5
    1
    +Subproject commit 99ec2e9ef46c2e4cef7bf0d4505d66725ea0a842

  • libraries/containers
    1
    -Subproject commit 801b06e5d4392b028e519d5ca116a2881d559721
    1
    +Subproject commit 6fd4a83966fca76eac5b0ac7ad0d2232bf9d1f93

  • libraries/exceptions
    1
    -Subproject commit b6c4290124eb1138358bf04ad9f33e67f6c5c1d8
    1
    +Subproject commit 9fbde92331ba64ffc49f90d49a3bfb26b6bf197c

  • libraries/filepath
    1
    -Subproject commit cbcd0ccf92f47e6c10fb9cc513a7b26facfc19fe
    1
    +Subproject commit e4cc73a60a7fa0111715292626fd0e1b01d4d39e

  • libraries/ghc-compact/ghc-compact.cabal
    ... ... @@ -40,7 +40,7 @@ library
    40 40
         CPP
    
    41 41
     
    
    42 42
       build-depends: base       >= 4.9.0 && < 4.23,
    
    43
    -                 bytestring >= 0.10.6.0 && <0.13
    
    43
    +                 bytestring >= 0.10.6.0 && <0.14
    
    44 44
       ghc-options: -Wall
    
    45 45
     
    
    46 46
       exposed-modules: GHC.Compact
    

  • libraries/os-string
    1
    -Subproject commit 2e693aad07540173a0169971b27c9acac28eeff1
    1
    +Subproject commit 13b7bef9c40cd454a6e7b357dece7262e5276744

  • libraries/text
    1
    -Subproject commit 5f343f668f421bfb30cead594e52d0ac6206ff67
    1
    +Subproject commit b2f86f8a010dabcbdfb32f4b7f3d95259d9107fa

  • libraries/time
    1
    -Subproject commit 507f50844802f1469ba6cadfeefd4e3fecee0416
    1
    +Subproject commit 4ae1bbd587bcbe0c643cefb00337ce85e0ff2507