Try to find which version control system contains the cwd directory.

        Returns the VersionControl superclass e.g. Git, if none were
        found this will raise a NotImplementedError.
352682
def which(cwd=None):  # pragma: no cover
        
        if cwd is None:
            cwd = os.getcwd()
        for (k, using_vc) in globals().items():
            if k.startswith('using_') and using_vc(cwd=cwd):
                return VersionControl.from_string(k[6:])

        # Not supported (yet)
        raise NotImplementedError("Unknown version control system, "
                                  "or you're not in the project directory.")
918764
function findRepos(callback) {
  var cwd = process.cwd(),
      tasks = [];

  fs.readdir(cwd, function(err, files) {
    if (err) return callback(err);

    var repos = [];
    files.forEach(function(file) {
      if (fs.existsSync(path.join(cwd, file, '.git'))) {
        repos.push(path.join(cwd, file));
      }
    });

    if (repos.length === 0) {
      return callback(new Error('No repositories found'));
    }

    repos.forEach(function(dir) {
      tasks.push(function(done) {
        done(err, git(dir));
      });
    });

    async.series(tasks, function(err, results) {
      callback(err, results);
    });
  });
}
257629
function getDirectoryFromBowerRc(cwd) {
    var bowerrc = path.join(cwd, '.bowerrc');

    if (!fs.existsSync(bowerrc)) {
        return '';
    }

    var bower_config = {};
    try {
        bower_config = JSON.parse(fs.readFileSync(bowerrc));
    } catch (err) {
        return '';
    }

    return bower_config.directory;
}
669860
def check_root(self):
        '''
        
        '''
        # No need to pass an environment to self.root() here since per-saltenv
        # configuration is a gitfs-only feature and check_root() is not used
        # for gitfs.
        root_dir = salt.utils.path.join(self.cachedir, self.root()).rstrip(os.sep)
        if os.path.isdir(root_dir):
            return root_dir
        log.error(
            'Root path \'%s\' not present in %s remote \'%s\', '
            'skipping.', self.root(), self.role, self.id
        )
        return None
406292
def get_directory_relative_to_git_root(directory: str):
    
    return os.path.relpath(os.path.realpath(directory), get_git_root_directory(directory))
465301
def search_for_vcs(self, dependency):  # type: (VCSDependency) -> List[Package]
        
        if dependency.vcs != "git":
            raise ValueError("Unsupported VCS dependency {}".format(dependency.vcs))

        tmp_dir = Path(mkdtemp(prefix="pypoetry-git-{}".format(dependency.name)))

        try:
            git = Git()
            git.clone(dependency.source, tmp_dir)
            git.checkout(dependency.reference, tmp_dir)
            revision = git.rev_parse(dependency.reference, tmp_dir).strip()

            if dependency.tag or dependency.rev:
                revision = dependency.reference

            directory_dependency = DirectoryDependency(
                dependency.name,
                tmp_dir,
                category=dependency.category,
                optional=dependency.is_optional(),
            )
            for extra in dependency.extras:
                directory_dependency.extras.append(extra)

            package = self.search_for_directory(directory_dependency)[0]

            package.source_type = "git"
            package.source_url = dependency.source
            package.source_reference = revision
        except Exception:
            raise
        finally:
            safe_rmtree(str(tmp_dir))

        return [package]
90996
def versions_from_parentdir(parentdir_prefix, root, verbose):
    
    dirname = os.path.basename(root)
    if not dirname.startswith(parentdir_prefix):
        if verbose:
            print("guessing rootdir is '%s', but '%s' doesn't start with "
                  "prefix '%s'" % (root, dirname, parentdir_prefix))
        raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
    return {"version": dirname[len(parentdir_prefix):],
            "full-revisionid": None,
            "dirty": False, "error": None}
35238
def ServiceWorker_inspectWorker(self, versionId):
		
		assert isinstance(versionId, (str,)
		    ), "Argument 'versionId' must be of type '['str']'. Received type: '%s'" % type(
		    versionId)
		subdom_funcs = self.synchronous_command('ServiceWorker.inspectWorker',
		    versionId=versionId)
		return subdom_funcs
542581
def _get_version():
    '''
    
    '''
    version_string = __salt__['cmd.run'](
        [_check_pkgin(), '-v'],
        output_loglevel='trace')
    if version_string is None:
        # Dunno why it would, but...
        return False

    version_match = VERSION_MATCH.search(version_string)
    if not version_match:
        return False

    return version_match.group(1).split('.')
945818
def cwd (self):
        
        path = self.urlparts[2].encode(self.filename_encoding, 'replace')
        dirname = path.strip('/')
        dirs = dirname.split('/')
        filename = dirs.pop()
        self.url_connection.cwd('/')
        for d in dirs:
            self.url_connection.cwd(d)
        return filename
1128946
def is_git_directory_clean(path_to_repo: Path,
                           search_parent_dirs: bool = True,
                           check_untracked: bool = False) -> None:
    
    repo = Repo(str(path_to_repo), search_parent_directories=search_parent_dirs)
    logger.debug("is_git_directory_clean check for repo in path={} from "\
                  "cwd={} with search_parent_directories={}".format(
                        path_to_repo, os.getcwd(), search_parent_dirs))

    # If there are changes to already tracked files
    if repo.is_dirty():
        raise DirtyRepoException("Changes to the index or working tree."
                                 "Commit them first .")
    if check_untracked:
        if repo.untracked_files:
            raise DirtyRepoException("Untracked files. Commit them first.")
123357
def cwd_decorator(func):
    

    def wrapper(*args, **kw):
        cur_dir = os.getcwd()
        found = False
        for arg in sys.argv:
            if arg.endswith(".rst"):
                found = arg
                break

        if found:
            directory = os.path.dirname(found)
            if directory:
                os.chdir(directory)
        data = func(*args, **kw)
        os.chdir(cur_dir)
        return data

    return wrapper
47809
def additions_version():
    '''
    
    '''
    try:
        d = _additions_dir()
    except EnvironmentError:
        return False
    if d and os.listdir(d):
        return re.sub(r'^{0}-'.format(_additions_dir_prefix), '',
                os.path.basename(d))
    return False
157494
public function setCwd($cwd)
    {
        $this->hasCheckout = false;
        $this->hasClone = false;
        $this->isTemporary = false;

        if (is_null($cwd)) {
            $this->cwd = sys_get_temp_dir() . '/' . uniqid('git');

            // ensure the working directory exists (needed on windows)
            if (!is_dir($this->cwd)) {
                mkdir($this->cwd);
            }

            $this->isTemporary = true;
        } else {
            if (is_dir($cwd)) {
                if (is_dir($cwd . '/.git')) {
                    $this->hasClone = true;
                }
            }
            $this->cwd = $cwd;
        }

        return $this;
    }
1108069
function (options) {
  var git_repo_path = ((options && options['gcwd']) || process.cwd()) + '/.git';

  return fs.statAsync(git_repo_path)
    .call('isDirectory')
    .then(function (exist) {
      return exist && git_repo_path
    })
}
1055587
def _getResourceClass(self):
        
        if self.fromVirtualEnv:
            subcls = VirtualEnvResource
        elif os.path.isdir(self._resourcePath):
            subcls = DirectoryResource
        elif os.path.isfile(self._resourcePath):
            subcls = FileResource
        elif os.path.exists(self._resourcePath):
            raise AssertionError("Neither a file or a directory: '%s'" % self._resourcePath)
        else:
            raise AssertionError("No such file or directory: '%s'" % self._resourcePath)
        return subcls
1042266
def from_string(vc):
        """"""
        try:
            # Note: this means all version controls must have
            # a title naming convention (!)
            vc = globals()[vc.title()]
            assert(issubclass(vc, VersionControl))
            return vc
        except (KeyError, AssertionError):
            raise NotImplementedError("Unknown version control system.")