Builds the command that will be executed to find all files containing version placeholders.
341519
function buildPlaceholderFindCommand(packageDir) {
  if (platform() === 'win32') {
    return {
      binary: 'findstr',
      args: ['/msi', `${materialVersionPlaceholderText} ${ngVersionPlaceholderText} ${versionPlaceholderText}`, `${packageDir}\\*`]
    };
  } else {
    return {
      binary: 'grep',
      args: ['-ril', `${materialVersionPlaceholderText}\\|${ngVersionPlaceholderText}\\|${versionPlaceholderText}`, packageDir]
    };
  }
}
584457
def get_git_version(path):
    """"""
    branch_name = get_git_cleaned_branch_name(path)
    # Determine whether working copy is dirty (i.e. contains modified files)
    mods = run_cmd(path, 'git', 'status', '--porcelain', '--untracked-files=no')
    dirty = '.dirty' if mods else ''
    # Get a list of all commits on branch, with corresponding branch/tag refs
    # Each line looks something like: "d3e4d42 (HEAD, master, tag: v0.1)"
    git_output = run_cmd(path, 'git', 'log', '--pretty="%h%d"')
    commits = git_output.strip().replace('"', '').split('\n')
    num_commits_since_branch = len(commits)
    # Short hash of the latest commit
    short_commit_name = commits[0].partition(' ')[0]
    # A valid version is sequence of dotted numbers optionally prefixed by 'v'
    valid_version = re.compile(r'^v?([\.\d]+)$')

    def tagged_version(commit):
        """First tag on commit that is valid version, as a list of numbers."""
        refs = commit.partition(' ')[2]
        for ref in refs.lstrip('(').rstrip(')').split(', '):
            if ref.startswith('tag: '):
                tag = ref[5:].lower()
                found = valid_version.match(tag)
                if found:
                    return [int(v) for v in found.group(1).split('.') if v]
        return []
    # Walk back along branch and find first valid tagged version (or use 0.0)
    for commit in commits:
        version_numbers = tagged_version(commit)
        if version_numbers:
            break
    else:
        version_numbers = [0, 0]
    # It is a release if current commit has a version tag (and dir is clean)
    release = (commit == commits[0]) and not dirty
    if not release:
        # We are working towards the next (minor) release according to PEP 440
        version_numbers[-1] += 1
    version = '.'.join([str(v) for v in version_numbers])
    if not release:
        # Development version contains extra embellishments
        version = ("%s.dev%d+%s.%s%s" % (version, num_commits_since_branch,
                                         branch_name, short_commit_name, dirty))
    return version
547964
def hashes_get(versions_file, base_path):
    
    files = versions_file.files_get_all()
    result = {}
    for f in files:
        try:
            result[f] = functions.md5_file(base_path + f)
        except IOError:
            # Not all files exist for all versions.
            pass

    return result
737511
def match_version_pattern(filename, pattern):
  

  if "{VERSION}" not in pattern:
    raise ValueError("pattern does not contain a {VERSION} reference")
  pattern = pattern.replace('{VERSION}', '(?P<v>[\d\w\.\-_]+)')
  expr = re.compile(pattern)
  with open(filename) as fp:
    lines = fp.read().split('\n')
  for i, line in enumerate(lines):
    match = expr.search(line)
    if match:
      return Match(filename, lines, line_index=i,
          version=Version(match.group('v')), span=match.span('v'))
  return None
301875
public static boolean checkVersionDirName(File versionDir) {
        return (versionDir.isDirectory() && versionDir.getName().contains("version-") && !versionDir.getName()
                                                                                                    .endsWith(".bak"));
    }
1200108
def _get_scope_versions(self, pkg_versions):
        '''
        
        '''
        get_in_versions = []
        for p_version in pkg_versions:
            if fnmatch.fnmatch(p_version, self.version):
                get_in_versions.append(p_version)
        return get_in_versions
1125690
def generate_version_file(infile='version.py.in', outfile='version.py', **kwargs):
    

    if not os.path.exists(outfile) and os.path.exists(infile):
        now = datetime.datetime.now()
        repo_hash = ''
        git_path = find_exe('git')
        if git_path is not None:
            git_cmd = [find_exe('git'), 'log', '--format=%h', '-1']
            repo_hash = subprocess.Popen(git_cmd, stdout=subprocess.PIPE).communicate()[0].strip()
        if repo_hash.strip() == '':
            repo_hash = '{now.hour}.{now.minute}.{now.second}'.format(now=now)

        sub_dict = {
            'repo_hash': repo_hash,
            'build_date': '{now.year}.{now.month}.{now.day}'.format(now=now),
            'build_time': '{now.hour}.{now.minute}.{now.second}'.format(now=now),
            'build_host': socket.gethostname(),
            'build_user': getpass.getuser()
        }
        sub_dict.update(**kwargs)

        with open(infile) as version_in:
            version_data = version_in.read()
            version_final = string.Template(version_data).safe_substitute(sub_dict)

        with open(outfile, 'w') as version_out:
            version_out.write(version_final)

    return outfile if os.path.exists(outfile) else None
577222
def git_versions_from_vcs(tag_prefix, root, verbose=False):
    

    # this runs 'git' from the root of the source tree. This only gets called
    # if the git-archive 'subst' keywords were *not* expanded, and
    # _version.py hasn't already been rewritten with a short version string,
    # meaning we're inside a checked out source tree.

    if not os.path.exists(os.path.join(root, ".git")):
        if verbose:
            print("no .git in %s" % root)
        return {}

    GITS = ["git"]
    if sys.platform == "win32":
        GITS = ["git.cmd", "git.exe"]

    versions = {}

    full_revisionid = run_command(GITS, ["rev-parse", "HEAD"], cwd=root)
    if full_revisionid is None:
        return {}
    versions["full_revisionid"] = full_revisionid.strip()

    d = run_command(GITS,
                    ["describe", "--tags", "--dirty", "--always", "--long"],
                    cwd=root)
    if d is None:
        return {}
    d = d.strip()
    # "TAG-DIST-gHASH[-dirty]" , where DIST might be "0"
    # or just "HASH[-dirty]" if there are no ancestor tags

    versions["long"] = d

    mo1 = re.search(r"^(.*)-(\d+)-g([0-9a-f]+)(-dirty)?$", d)
    mo2 = re.search(r"^([0-9a-f]+)(-dirty)?$", d)
    if mo1:
        rawtag = mo1.group(1)
        if not rawtag.startswith(tag_prefix):
            if verbose:
                print("tag '%s' doesn't start with prefix '%s'" % (rawtag, tag_prefix))
            return {}
        tag = rawtag[len(tag_prefix):]
        versions["closest_tag"] = tag
        versions["distance"] = int(mo1.group(2))
        versions["short_revisionid"] = mo1.group(3)
        versions["dirty"] = bool(mo1.group(4))
        versions["pep440"] = tag
        if versions["distance"]:
            versions["describe"] = d
            versions["pep440"] += ".post%d" % versions["distance"]
        else:
            versions["describe"] = tag
            if versions["dirty"]:
                versions["describe"] += "-dirty"
        if versions["dirty"]:
            # not strictly correct, as X.dev0 sorts "earlier" than X, but we
            # need some way to distinguish the two. You shouldn't be shipping
            # -dirty code anyways.
            versions["pep440"] += ".dev0"
        versions["default"] = versions["describe"]

    elif mo2: # no ancestor tags
        versions["closest_tag"] = None
        versions["short_revisionid"] = mo2.group(1)
        versions["dirty"] = bool(mo2.group(2))
        # count revisions to compute ["distance"]
        commits = run_command(GITS, ["rev-list", "--count", "HEAD"], cwd=root)
        if commits is None:
            return {}
        versions["distance"] = int(commits.strip())
        versions["pep440"] = "0"
        if versions["distance"]:
            versions["pep440"] += ".post%d" % versions["distance"]
        if versions["dirty"]:
            versions["pep440"] += ".dev0" # same concern as above
        versions["describe"] = d
        versions["default"] = "0-%d-g%s" % (versions["distance"], d)
    else:
        return {}
    versions["dash_dirty"] = "-dirty" if versions["dirty"] else ""
    versions["closest_tag_or_zero"] = versions["closest_tag"] or "0"
    if versions["distance"] == 0:
        versions["dash_distance"] = ""
    else:
        versions["dash_distance"] = "-%d" % versions["distance"]

    return versions
316488
protected Collection<FileSystemDatasetVersion> listQualifiedRawFileSystemDatasetVersions(Collection<FileSystemDatasetVersion> allVersions) {
    return Lists.newArrayList(Collections2.filter(allVersions, new Predicate<FileSystemDatasetVersion>() {
      @Override
      public boolean apply(FileSystemDatasetVersion version) {
        Iterable<Path> refinedDatasetPaths = getRefinedDatasetPaths(version);
        try {
          Optional<Long> latestRawDatasetModTime = getLatestModTime(version.getPaths());
          Optional<Long> latestRefinedDatasetModTime = getLatestModTime(refinedDatasetPaths);
          return latestRawDatasetModTime.isPresent() && latestRefinedDatasetModTime.isPresent()
              && latestRawDatasetModTime.get() <= latestRefinedDatasetModTime.get();
        } catch (IOException e) {
          throw new RuntimeException("Failed to get modification time", e);
        }
      }
    }));
  }
452120
def versions(runas=None):
    '''
    
    '''
    ret = _rbenv_exec(['versions', '--bare'], runas=runas)
    return [] if ret is False else ret.splitlines()
834686
def get_cli():
    """"""
    parser = argparse.ArgumentParser(
        prog="auto_version",
        description="auto version v%s: a tool to control version numbers" % __version__,
    )
    parser.add_argument(
        "--target",
        action="append",
        default=[],
        help="Files containing version info. "
        "Assumes unique variable names between files. (default: %s)."
        % (config.targets,),
    )
    parser.add_argument(
        "--bump",
        choices=SemVerSigFig,
        help="Bumps the specified part of SemVer string. "
        "Use this locally to correctly modify the version file.",
    )
    parser.add_argument(
        "--news",
        "--file-triggers",
        action="store_true",
        dest="file_triggers",
        help="Detects need to bump based on presence of files (as specified in config).",
    )
    parser.add_argument(
        "--set",
        help="Set the SemVer string. Use this locally to set the project version explicitly.",
    )
    parser.add_argument(
        "--set-patch-count",
        action="store_true",
        help="Sets the patch number to the commit count.",
    )
    parser.add_argument(
        "--lock",
        action="store_true",
        help="Locks the SemVer string. "
        "Lock will remain for another call to autoversion before being cleared.",
    )
    parser.add_argument(
        "--release",
        action="store_true",
        default=False,
        help="Marks as a release build, which flags the build as released.",
    )
    parser.add_argument(
        "--version",
        action="store_true",
        default=False,
        help="Prints the version of auto_version itself (self-version).",
    )
    parser.add_argument("--config", help="Configuration file path.")
    parser.add_argument(
        "-v",
        "--verbosity",
        action="count",
        default=0,
        help="increase output verbosity. " "can be specified multiple times",
    )
    return parser.parse_known_args()
398969
def handle_versions(repo, **kwargs):
    """"""
    log.info('versions: %s %s' %(repo, kwargs))
    if not hasattr(repo, 'versions'):
        return []
    return [v.serialize() for v in repo.versions(**kwargs)]
926808
def check_version(ctx, param, value):
    """"""
    if ctx.resilient_parsing:
        return

    if not value and ctx.invoked_subcommand != 'run':
        ctx.call_on_close(_check_version)
1009061
def _version_find_existing():
    
    _tool_run('git fetch origin -t')
    git_tags = [x for x in (y.strip() for y in (_tool_run('git tag -l')
                                                .stdout.split('\n'))) if x]
    return {tuple(int(n) if n else 0 for n in m.groups())
            for m in (_version_re.match(t) for t in git_tags) if m}
1327881
function ( version, options ){
			
		var matches;
		
		//First if version is 'readme' or 'plugin' version values
		if( version === 'readme' ){
			var readme = grunt.file.read( options.readme );
			matches = readme.match( new RegExp("^Stable tag:\\s*(\\S+)","im") );
			
			if( matches.length <= 1 ){
				grunt.fail.fatal( 'Could not find version in "' + options.readme + '"' );
			}
			version = matches[1];
		
		}else if( version === 'plugin' ){
			var plugin = grunt.file.read( options.plugin );
			matches = plugin.match( new RegExp("^[\* ]*Version:\\s*(\\S+)","im") );
			if( matches.length <= 1 ){
				grunt.fail.fatal( 'Could not find version in "' + options.readme + '"' );
			}
			version = matches[1];
		}
		
		return version;
	}
137118
def extract_version(filepath='jeni.py', name='__version__'):
    
    context = {}
    for line in open(filepath):
        if name in line:
            exec(line, context)
            break
    else:
        raise RuntimeError('{} not found in {}'.format(name, filepath))
    return context[name]
640757
def find_version_by_regex(file_source):  # type: (str)->Optional[str]
    
    if not file_source:
        return None
    version_match = re.search(r"^version=['\"]([^'\"]*)['\"]", file_source, re.M)
    if version_match:
        return version_match.group(1)
    return None