Pretty version

        :param diff_to_increase_ratio: Ratio to convert number of changes into
            version increases
        :return: string: Pretty version of this repository
889
def get_pretty_version(self, diff_to_increase_ratio):
        
        version = self.get_version(diff_to_increase_ratio)
        build = self.get_last_commit_hash()
        return str(version) + " (" + build + ")"
587003
def commit_new_version(version: str):
    

    check_repo()
    commit_message = config.get('semantic_release', 'commit_message')
    message = '{0}\n\n{1}'.format(version, commit_message)
    repo.git.add(config.get('semantic_release', 'version_variable').split(':')[0])
    return repo.git.commit(m=message, author="semantic-release <semantic-release>")
495467
def _compare_versions(v1, v2):
    
    def normalize(v):
        # strip trailing .0 or .00 or .0.0 or ...
        v = re.sub(r'(\.0+)*$', '', v)
        result = []
        for part in v.split('.'):
            # just digits
            m = re.match(r'^(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                continue
            # digits letters
            m = re.match(r'^(\d+)([a-zA-Z]+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                continue
            # digits letters digits
            m = re.match(r'^(\d+)([a-zA-Z]+)(\d+)$', part)
            if m:
                result.append(int(m.group(1)))
                result.append(m.group(2))
                result.append(int(m.group(3)))
                continue
        return tuple(result)

    n1 = normalize(v1)
    n2 = normalize(v2)

    return (n1 > n2) - (n1 < n2)
1355716
def get_version(version=None):
    

    if version[4] > 0:  # 0.2.1-alpha.1
        return "%s.%s.%s-%s.%s" % (version[0], version[1], version[2], version[3], version[4])
    elif version[3] != '':  # 0.2.1-alpha
        return "%s.%s.%s-%s" % (version[0], version[1], version[2], version[3])
    elif version[2] > 0:  # 0.2.1
        return "%s.%s.%s" % (version[0], version[1], version[2])
    else:  # 0.2
        return "%s.%s" % (version[0], version[1])
604615
def version(self) -> str:
        
        version: str = (
            str(self._major) + '.' +
            str(self._minor) + '.' +
            str(self._patch)
        )
        return version
514234
def version(self):
        
        if self.find:
            return self.meta.sp + split_package(self.find)[1]
        return ""
1002025
def _nested_changes(changes):
    '''
    
    '''
    ret = '\n'
    ret += salt.output.out_format(
            changes,
            'nested',
            __opts__,
            nested_indent=14)
    return ret
514161
def dump_br_version(project):
    
    normalized = get_version(project)
    sha = subprocess.check_output(
        ['git', 'rev-parse', 'HEAD'], cwd=HERE).strip()
    branch = subprocess.check_output(
        ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=HERE).strip()
    pref = br_version_prefixes[project]
    return json.dumps({pref+'_version': normalized,
                       pref+'_sha': sha,
                       pref+'_branch': branch})
1197411
def generate_version(max_major: int = 1, max_minor: int = 7,
                     max_patch: int = 15) -> str:
    
    major = randint(0, max_major)
    minor = randint(0, max_minor)
    patch = randint(0, max_patch)
    return '{:d}.{:d}.{:d}'.format(major, minor, patch)
718869
def _upgrade(self):
        
        logging.debug("[FeedbackCalibration]._upgrade()")
        version = Version.fromstring(self.version)
        logging.debug('[FeedbackCalibration] version=%s, class_version=%s',
                      str(version), self.class_version)
        if version > Version.fromstring(self.class_version):
            logging.debug('[FeedbackCalibration] version>class_version')
            raise FutureVersionError(Version.fromstring(self.class_version),
                                     version)
        elif version < Version.fromstring(self.class_version):
            if version < Version(0, 1):
                self._c_filler = None
                self._c_drop = None
                self.version = str(Version(0, 1))
            if version < Version(0, 2):
                self.hw_version = Version(1)
                self.version = str(Version(0, 2))
                logging.info('[FeedbackCalibration] upgrade to version %s',
                             self.version)
            if version < Version(0, 2):
                self.hw_version = Version(1)
                self.version = str(Version(0, 2))
                logging.info('[FeedbackCalibration] upgrade to version %s',
                             self.version)
            if version < Version(0, 3):
                self.version = str(Version(0, 3))
                logging.info('[FeedbackCalibration] upgrade to version %s',
                             self.version)
1312043
def get_diff(self, commit, other_commit):
        
        print(other_commit, "VS", commit)
        diff = self.repo.git.diff(commit, other_commit)
        return Diff(diff).get_totals()
717550
def normalize_version(version):
    
    rv = []
    for x in version.split("."):
        try:
            rv.append(int(x))
        except ValueError:
            for y in re.split("([0-9]+)", x):
                if y == '':
                    continue
                try:
                    rv.append(int(y))
                except ValueError:
                    rv.append(y)
    return rv
63556
def version_str(version):
    
    if isinstance(version, str):
        return version
    elif isinstance(version, tuple):
        return '.'.join([str(int(x)) for x in version])
    else:
        raise ValueError("Invalid version: %s" % version)
1240678
def get_diff_amounts(self):
        
        diffs = []

        last_commit = None
        for commit in self.repo.iter_commits():
            if last_commit is not None:
                diff = self.get_diff(commit.hexsha, last_commit.hexsha)
                total_changed = diff[Diff.ADD] + diff[Diff.DEL]
                diffs.append(total_changed)

            last_commit = commit

        return diffs
1325062
def getVersion():  # @NoSelf
        
        print('epochs version:', str(CDFepoch.version) + '.' +
              str(CDFepoch.release) + '.'+str(CDFepoch.increment))
360003
def update_git_devstr(version, path=None):
    

    try:
        # Quick way to determine if we're in git or not - returns '' if not
        devstr = get_git_devstr(sha=True, show_warning=False, path=path)
    except OSError:
        return version

    if not devstr:
        # Probably not in git so just pass silently
        return version

    if 'dev' in version:  # update to the current git revision
        version_base = version.split('.dev', 1)[0]
        devstr = get_git_devstr(sha=False, show_warning=False, path=path)

        return version_base + '.dev' + devstr
    else:
        # otherwise it's already the true/release version
        return version
112730
def make_diff(current, revision):
    """"""
    the_diff = []
    dmp = diff_match_patch()

    for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())):
        # These exclusions really should be configurable
        if field == 'id' or field.endswith('_rendered'):
            continue
        # KeyError's may happen if the database structure changes
        # between the creation of revisions. This isn't ideal,
        # but should not be a fatal error.
        # Log this?
        missing_field = False
        try:
            cur_val = current.field_dict[field] or ""
        except KeyError:
            cur_val = "No such field in latest version\n"
            missing_field = True
        try:
            old_val = revision.field_dict[field] or ""
        except KeyError:
            old_val = "No such field in old version\n"
            missing_field = True
        if missing_field:
            # Ensure that the complete texts are marked as changed
            # so new entries containing any of the marker words
            # don't show up as differences
            diffs = [(dmp.DIFF_DELETE, old_val), (dmp.DIFF_INSERT, cur_val)]
            patch =  dmp.diff_prettyHtml(diffs)
        elif isinstance(cur_val, Markup):
            # we roll our own diff here, so we can compare of the raw
            # markdown, rather than the rendered result.
            if cur_val.raw == old_val.raw:
                continue
            diffs = dmp.diff_main(old_val.raw, cur_val.raw)
            patch =  dmp.diff_prettyHtml(diffs)
        elif cur_val == old_val:
            continue
        else:
            # Compare the actual field values
            diffs = dmp.diff_main(force_text(old_val), force_text(cur_val))
            patch = dmp.diff_prettyHtml(diffs)
        the_diff.append((field, patch))

    the_diff.sort()
    return the_diff