def get_diff_range(diff_range=None, patches_branch=None, branch=None): vtag_from, vtag_to = None, None if diff_range: n = len(diff_range) if n > 2: raise exception.InvalidUsage(why="diff only supports one or two " "positional parameters.") if n == 2: vtag_from, vtag_to = diff_range else: vtag_to = diff_range[0] if not vtag_from: if not patches_branch: if not branch: branch = guess.current_branch() patches_branch = guess.patches_branch(branch) if not git.ref_exists('refs/remotes/%s' % patches_branch): msg=("Patches branch not found: %s\n" "Can't guess current version.\n\n" "a) provide git tags/refs yourself a la:\n" " $ rdopkg reqdiff 1.1.1 2.2.2\n\n" "b) add git remote with expected patches branch" % patches_branch) raise exception.CantGuess(msg=msg) vtag_from = git.get_latest_tag(branch=patches_branch) if not vtag_to: upstream_branch = guess.upstream_branch() vtag_to = git.get_latest_tag(branch=upstream_branch) return { 'version_tag_from': vtag_from, 'version_tag_to': vtag_to }
def show_package_env(package, version, branch, patches_branch, local_patches_branch, release=None, dist=None, version_tag_style=None): def _putv(title, val): print("{t.bold}{title}{t.normal} {val}" .format(title=title, val=val, t=log.term)) osdist = guess.osdist() upstream_branch = guess.upstream_branch() if not git.ref_exists('refs/remotes/%s' % upstream_branch): upstream_version = 'upstream remote/branch not found' else: upstream_version = guess.upstream_version(branch=upstream_branch) if not upstream_version: upstream_version = 'no version tag found' print _putv('Package: ', package) _putv('Version: ', version) _putv('Upstream: ', upstream_version) _putv('Tag style:', version_tag_style or 'X.Y.Z') _putv('OS dist: ', osdist) print _putv('Dist-git branch: ', branch) _putv('Local patches branch: ', local_patches_branch) _putv('Remote patches branch: ', patches_branch) _putv('Remote upstream branch:', upstream_branch or 'not found') print if osdist == 'RDO': rlsdist = '%s/%s' % (release or 'unknown', dist or 'unknown') _putv('RDO release/dist guess:', rlsdist) print
def show_package_env( package, version, branch, patches_branch, local_patches_branch, release=None, dist=None, version_tag_style=None ): def _putv(title, val): print("{t.bold}{title}{t.normal} {val}".format(title=title, val=val, t=log.term)) osdist = guess.osdist() upstream_branch = guess.upstream_branch() if not git.ref_exists("refs/remotes/%s" % upstream_branch): upstream_version = "upstream remote/branch not found" else: upstream_version = guess.upstream_version(branch=upstream_branch) if not upstream_version: upstream_version = "no version tag found" print _putv("Package: ", package) _putv("Version: ", version) _putv("Upstream: ", upstream_version) _putv("Tag style:", version_tag_style or "X.Y.Z") _putv("OS dist: ", osdist) print _putv("Dist-git branch: ", branch) _putv("Local patches branch: ", local_patches_branch) _putv("Remote patches branch: ", patches_branch) _putv("Remote upstream branch:", upstream_branch or "not found") print if osdist == "RDO": rlsdist = "%s/%s" % (release or "unknown", dist or "unknown") _putv("RDO release/dist guess:", rlsdist) print
def new_version_setup(new_version=None): args = {} if not new_version: 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 = git.get_latest_tag(ub) 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 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' return args
def new_version_setup(patches_branch=None, local_patches=False, 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 %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 local_patches: if not patches_branch or \ not git.ref_exists('refs/remotes/' + patches_branch): log.warn("Patches branch '%s' not found. Running in --bump-only " "mode." % patches_branch) args['bump_only'] = True return args