Beispiel #1
0
def push(repository, public_release, branch, **extra_kwargs):
    if not public_release:
        return

    chdir(repository)
    doechocall('Pushing main repository changes to GitHub',
               ['git', 'push', 'upstream', branch, '--follow-tags'])
Beispiel #2
0
def check_local_repo(repository, branch, release_name, rev, **extra_kwargs):
    # releasing from the local clone has the advantage we can prepare the
    # release offline and only push and upload it when we get back online
    s = f"Using local repository at: {repository} !"
    print("\n", s, "\n", "=" * len(s), "\n", sep='')

    status = call(['git', 'status', '-s', '-b'])
    lines = status.splitlines()
    statusline, lines = lines[0], lines[1:]
    curbranch = branchname(statusline)
    if curbranch != branch:
        print(f"{branch} is not the current branch ({curbranch}). "
              f"Please use 'git checkout {branch}'.")
        exit(1)

    if lines:
        uncommited = sum(1 for line in lines if line[1] in 'MDAU')
        untracked = sum(1 for line in lines if line.startswith('??'))
        print(f'Warning: there are {uncommited:d} files with uncommitted changes and {untracked:d} untracked files:')
        print('\n'.join(lines))
        if no('Do you want to continue?'):
            exit(1)

    ahead = call(['git', 'log', '--format=format:%H', f'origin/{branch}..{branch}'])
    num_ahead = len(ahead.splitlines())
    print(f"Branch '{branch}' is {num_ahead:d} commits ahead of 'origin/{branch}'", end='')
    if num_ahead:
        if yes(', do you want to push?'):
            doechocall('Pushing changes', ['git', 'push'])
    else:
        print()

    if no(f"Release version {release_name} ({rev})?"):
        exit(1)
Beispiel #3
0
def update_version(build_dir, release_name, package_name, module_name, **extra_kwargs):
    chdir(build_dir)

    version = short(release_name)
    # meta.yaml
    meta_file = join('condarecipe', package_name, 'meta.yaml')
    changes = [('version: ', f"  version: {version}"),
               ('git_tag: ', f"  git_tag: {version}")]
    replace_lines(meta_file, changes)

    # __init__.py
    init_file = join(module_name, '__init__.py')
    changes = [('__version__ =', f"__version__ = '{version}'")]
    replace_lines(init_file, changes)

    # setup.py
    setup_file = 'setup.py'
    changes = [('VERSION =', f"VERSION = '{version}'")]
    replace_lines(setup_file, changes)

    # check, commit and push
    print(echocall(['git', 'status', '-s']))
    print(echocall(['git', 'diff', meta_file, init_file, setup_file]))
    if no('Do the version update changes look right?'):
        exit(1)
    doechocall('Adding', ['git', 'add', meta_file, init_file, setup_file])
    doechocall('Committing', ['git', 'commit', '-m', f'bump version to {version}'])
    print(echocall(['git', 'log', '-1']))
Beispiel #4
0
def update_version_conda_forge_package(build_dir, version, main_repository,
                                       **extra_kwargs):
    chdir(build_dir)

    # compute sha256 of archive of current release
    url = main_repository + f'/archive/{version}.tar.gz'
    print(f'Computing SHA256 from archive {url}', end=' ')
    with request.urlopen(url) as response:
        sha256 = hashlib.sha256(response.read()).hexdigest()
        print('done.')
        print('SHA256: ', sha256)

    # set version and sha256 in meta.yml file
    meta_file = r'recipe\meta.yaml'
    changes = [('set version', f'{{% set version = "{version}" %}}'),
               ('set sha256', f'{{% set sha256 = "{sha256}" %}}')]
    replace_lines(meta_file, changes)

    # add, commit and push
    print(echocall(['git', 'status', '-s']))
    print(echocall(['git', 'diff', meta_file]))
    if no('Does that last changes look right?'):
        exit(1)
    doechocall('Adding', ['git', 'add', meta_file])
    doechocall('Commiting',
               ['git', 'commit', '-m', f'bump version to {version}'])
Beispiel #5
0
def pull(repository, public_release, build_dir, branch, **extra_kwargs):
    if not public_release:
        return

    # pull the changelog commits to the branch (usually master)
    # and the release tag (which refers to the last commit)
    chdir(repository)
    doechocall(f'Pulling changes in {repository}',
               ['git', 'pull', '--ff-only', '--tags', build_dir, branch])
Beispiel #6
0
def clone_repository(tmp_dir, branch, repository, **extra_kwargs):
    chdir(tmp_dir)

    # make a temporary clone in /tmp. The goal is to make sure we do not include extra/unversioned files. For the -src
    # archive, I don't think there is a risk given that we do it via git, but the risk is there for the bundles
    # (src/build is not always clean, examples, editor, ...)

    # Since this script updates files (update_changelog), we need to get those changes propagated to GitHub. I do that
    # by updating the temporary clone then push twice: first from the temporary clone to the "working copy clone" (eg
    # ~/devel/project) then to GitHub from there. The alternative to modify the "working copy clone" directly is worse
    # because it needs more complicated path handling that the 2 push approach.
    doechocall('Cloning repository', ['git', 'clone', '-b', branch, repository, 'build'])
Beispiel #7
0
def push_conda_forge(build_dir, branch, **extra_kwargs):
    chdir(build_dir)
    doechocall('Pushing changes to GitHub', ['git', 'push', 'origin', branch])