Beispiel #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
Beispiel #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
Beispiel #3
0
def new_version_setup(patches_branch=None, new_version=None,
                      version_tag_style=None):
    args = {}
    if new_version:
        # support both version and tag
        ver, _ = guess.tag2version(new_version)
        if ver != new_version:
            new_version = ver
            args['new_version'] = new_version
        new_version_tag = guess.version2tag(new_version, version_tag_style)
    else:
        ub = guess.upstream_branch()
        if not git.ref_exists('refs/remotes/%s' % ub):
            msg=("Upstream branch not found: %s\n"
                 "Can't guess latest version.\n\n"
                 "a) provide new version (git tag) yourself\n"
                 "   $ rdopkg new-version 1.2.3\n\n"
                 "b) add upstream git remote:\n"
                 "   $ git remote add -f upstream GIT_URL\n"
                 % ub)
            raise exception.CantGuess(msg=msg)
        new_version_tag = git.get_latest_tag(ub)
        new_version, _ = guess.tag2version(new_version_tag)
        args['new_version'] = new_version
        log.info("Latest version detected from %s: %s" % (ub, new_version))
    args['changes'] = ['Update to upstream %s' % new_version]
    args['new_patches_base'] = new_version_tag
    spec = specfile.Spec()
    rpm_version = spec.get_tag('Version')
    new_rpm_version, new_milestone = specfile.version_parts(new_version)
    args['new_rpm_version'] = new_rpm_version
    if new_milestone:
        args['new_milestone'] = new_milestone
    if rpm_version != new_rpm_version:
        if new_milestone:
            args['new_release'] = '0.1'
        else:
            args['new_release'] = '1'
    if not patches_branch or not git.branch_exists(patches_branch):
        log.warn("Patches branch %s not found. Running in --bump-only mode." %
                 patches_branch)
        args['bump_only'] = True
    return args
Beispiel #4
0
def _reset_branch(branch, remote_branch):
    if git.branch_exists(branch):
        git('update-ref', 'refs/heads/%s' % branch,
            'refs/remotes/%s' % remote_branch)
    else:
        git.create_branch(branch, remote_branch)
Beispiel #5
0
def _reset_branch(branch, remote_branch):
    if git.branch_exists(branch):
        git("update-ref", "refs/heads/%s" % branch, "refs/remotes/%s" % remote_branch)
    else:
        git.create_branch(branch, remote_branch)