Ejemplo n.º 1
0
def get_package_env(version=None, release=None, dist=None,
                    patches_branch=None, local_patches_branch=None):
    branch = git.current_branch()
    if branch.endswith('-patches'):
        branch = branch[:-8]
        if git.branch_exists(branch):
            log.info("This looks like -patches branch. Assuming distgit branch: "
                    "%s" % branch)
            git.checkout(branch)
        else:
            raise exception.InvalidUsage(
                why="This action must be run on a distgit branch.")
    args = {
        'package': guess.package(),
        'branch': branch,
    }
    if not release or not dist:
        _release, _dist = guess.osreleasedist(branch, default=(None, None))
        if not release and _release:
            args['release'] = _release
        if not dist and _dist:
            args['dist'] = _dist
    osdist = guess.osdist()
    if osdist == 'RHOS':
        log.info("RHOS package detected.")
        args['fedpkg'] = ['rhpkg']
    if not patches_branch:
        patches_branch = guess.patches_branch(branch, pkg=args['package'],
                                              osdist=osdist)
    args['patches_branch'] = patches_branch
    if not local_patches_branch:
        args['local_patches_branch'] = patches_branch.partition('/')[2]
    if not version:
        args['version'] = guess.current_version()
    return args
Ejemplo n.º 2
0
def get_package_env(version=None, release=None, dist=None, patches_branch=None, local_patches_branch=None):
    branch = git.current_branch()
    if branch.endswith("-patches"):
        branch = branch[:-8]
        if git.branch_exists(branch):
            log.info("This looks like -patches branch. Assuming distgit branch: " "%s" % branch)
            git.checkout(branch)
        else:
            raise exception.InvalidUsage(why="This action must be run on a distgit branch.")
    args = {"package": guess.package(), "branch": branch}
    if not release or not dist:
        _release, _dist = guess.osreleasedist(branch, default=(None, None))
        if not release and _release:
            args["release"] = _release
        if not dist and _dist:
            args["dist"] = _dist
    osdist = guess.osdist()
    if osdist == "RHOS":
        log.info("RHOS package detected.")
        args["fedpkg"] = ["rhpkg"]
    if not patches_branch:
        patches_branch = guess.patches_branch(branch, pkg=args["package"], osdist=osdist)
    args["patches_branch"] = patches_branch
    if not local_patches_branch:
        args["local_patches_branch"] = patches_branch.partition("/")[2]
    if not version:
        version = guess.current_version()
        args["version"] = version
    args["version_tag_style"] = guess.version_tag_style(version=version)

    return args
Ejemplo n.º 3
0
def rebase_patches_branch(
    new_version, local_patches_branch, patches_branch=None, local_patches=False, bump_only=False, version_tag_style=None
):
    if bump_only:
        return
    git.checkout(local_patches_branch)
    new_version_tag = guess.version2tag(new_version, version_tag_style)
    git("rebase", new_version_tag, direct=True)
    if local_patches or not patches_branch:
        return
    if _is_same_commit(local_patches_branch, patches_branch):
        log.info("%s is up to date, no need for push." % patches_branch)
        return
    try:
        remote, branch = git.remote_branch_split(patches_branch)
        helpers.confirm("Push %s to %s / %s (with --force)?" % (local_patches_branch, remote, branch))
        git("push", "--force", remote, "%s:%s" % (local_patches_branch, branch))
        # push the tag
        git("push", "--force", remote, new_version_tag)
    except exception.UserAbort:
        pass
Ejemplo n.º 4
0
def rebase_patches_branch(new_version, local_patches_branch,
                          patches_branch=None, local_patches=False,
                          bump_only=False):
    if bump_only:
        return
    git.checkout(local_patches_branch)
    git('rebase', new_version, direct=True)
    if local_patches or not patches_branch:
        return
    if _is_same_commit(local_patches_branch, patches_branch):
        log.info("%s is up to date, no need for push." % patches_branch)
        return
    try:
        remote, branch = git.remote_branch_split(patches_branch)
        helpers.confirm("Push %s to %s / %s (with --force)?" % (
            local_patches_branch, remote, branch))
        git('push', '--force', remote,
            '%s:%s' % (local_patches_branch, branch))
        # push the tag
        git('push', '--force', remote, new_version)
    except exception.UserAbort:
        pass
Ejemplo n.º 5
0
def _ensure_branch(branch):
    if not branch:
        return
    if git.current_branch() != branch:
        git.checkout(branch)