Returns the directory of the pillars (repo cache + branch + root)
556915
def pillar_dir(self):
        '''
        
        '''
        repo_dir = self.repo_dir
        root = self.root
        branch = self.branch
        if branch == 'trunk' or branch == 'base':
            working_dir = os.path.join(repo_dir, 'trunk', root)
            if not os.path.isdir(working_dir):
                log.error('Could not find %s/trunk/%s', self.repo_location, root)
            else:
                return os.path.normpath(working_dir)
        working_dir = os.path.join(repo_dir, 'branches', branch, root)
        if os.path.isdir(working_dir):
            return os.path.normpath(working_dir)
        working_dir = os.path.join(working_dir, 'tags', branch, root)
        if os.path.isdir(working_dir):
            return os.path.normpath(working_dir)
        log.error('Could not find %s/branches/%s/%s', self.repo_location, branch, root)
        return repo_dir
800795
def branches(type = :master, dir = Dir.pwd, _options = {})
      FalkorLib::Git.config("gitflow.branch.#{type}", dir)
      #confs[type.to_sym]
    end
333129
def ext_pillar(minion_id, pillar, *repos):  # pylint: disable=unused-argument
    '''
    
    '''
    opts = copy.deepcopy(__opts__)
    opts['pillar_roots'] = {}
    opts['__git_pillar'] = True
    git_pillar = salt.utils.gitfs.GitPillar(
        opts,
        repos,
        per_remote_overrides=PER_REMOTE_OVERRIDES,
        per_remote_only=PER_REMOTE_ONLY,
        global_only=GLOBAL_ONLY)
    if __opts__.get('__role') == 'minion':
        # If masterless, fetch the remotes. We'll need to remove this once
        # we make the minion daemon able to run standalone.
        git_pillar.fetch_remotes()
    git_pillar.checkout()
    ret = {}
    merge_strategy = __opts__.get(
        'pillar_source_merging_strategy',
        'smart'
    )
    merge_lists = __opts__.get(
        'pillar_merge_lists',
        False
    )
    for pillar_dir, env in six.iteritems(git_pillar.pillar_dirs):
        # Map env if env == '__env__' before checking the env value
        if env == '__env__':
            env = opts.get('pillarenv') \
                or opts.get('saltenv') \
                or opts.get('git_pillar_base')
            log.debug('__env__ maps to %s', env)

        # If pillarenv is set, only grab pillars with that match pillarenv
        if opts['pillarenv'] and env != opts['pillarenv']:
            log.debug(
                'env \'%s\' for pillar dir \'%s\' does not match '
                'pillarenv \'%s\', skipping',
                env, pillar_dir, opts['pillarenv']
            )
            continue
        if pillar_dir in git_pillar.pillar_linked_dirs:
            log.debug(
                'git_pillar is skipping processing on %s as it is a '
                'mounted repo', pillar_dir
            )
            continue
        else:
            log.debug(
                'git_pillar is processing pillar SLS from %s for pillar '
                'env \'%s\'', pillar_dir, env
            )

        pillar_roots = [pillar_dir]

        if __opts__['git_pillar_includes']:
            # Add the rest of the pillar_dirs in this environment to the
            # list, excluding the current pillar_dir being processed. This
            # is because it was already specified above as the first in the
            # list, so that its top file is sourced from the correct
            # location and not from another git_pillar remote.
            pillar_roots.extend(
                [d for (d, e) in six.iteritems(git_pillar.pillar_dirs)
                 if env == e and d != pillar_dir]
            )

        opts['pillar_roots'] = {env: pillar_roots}

        local_pillar = Pillar(opts, __grains__, minion_id, env)
        ret = salt.utils.dictupdate.merge(
            ret,
            local_pillar.compile_pillar(ext=False),
            strategy=merge_strategy,
            merge_lists=merge_lists
        )
    return ret
53433
def ext_pillar(minion_id,
               pillar,  # pylint: disable=W0613
               repo_string):
    '''
    
    '''
    # split the branch, repo name and optional extra (key=val) parameters.
    options = repo_string.strip().split()
    branch = options[0]
    repo_location = options[1]
    root = ''

    for extraopt in options[2:]:
        # Support multiple key=val attributes as custom parameters.
        DELIM = '='
        if DELIM not in extraopt:
            log.error('Incorrectly formatted extra parameter. '
                      'Missing \'%s\': %s', DELIM, extraopt)
        key, val = _extract_key_val(extraopt, DELIM)
        if key == 'root':
            root = val
        else:
            log.warning('Unrecognized extra parameter: %s', key)

    svnpil = SvnPillar(branch, repo_location, root, __opts__)

    # environment is "different" from the branch
    branch = (branch == 'trunk' and 'base' or branch)

    pillar_dir = svnpil.pillar_dir()
    log.debug("[pillar_roots][%s] = %s", branch, pillar_dir)

    # Don't recurse forever-- the Pillar object will re-call the ext_pillar
    # function
    if __opts__['pillar_roots'].get(branch, []) == [pillar_dir]:
        return {}
    svnpil.update()
    opts = deepcopy(__opts__)
    opts['pillar_roots'][branch] = [pillar_dir]
    pil = Pillar(opts, __grains__, minion_id, branch)
    return pil.compile_pillar(ext=False)
1253201
def repo_branches(self, repo):
        
        branches = []
        try:
            # switch to directory where repo will be cloned to
            status = self.path_dirs.apply_path(repo)
            if status[0]:
                cwd = status[1]
            else:
                self.logger.error('apply_path failed. Exiting repo_branches'
                                  ' with status ' + str(status))
                return status

            branch_output = check_output(shlex.split('git branch -a'),
                                         stderr=STDOUT,
                                         close_fds=True)
            branch_output = branch_output.split(b'\n')
            for branch in branch_output:
                br = branch.strip()
                if br.startswith(b'*'):
                    br = br[2:]
                if b'/' in br:
                    branches.append(br.rsplit(b'/', 1)[1].decode('utf-8'))
                elif br:
                    branches.append(br.decode('utf-8'))

            branches = list(set(branches))
            for branch in branches:
                try:
                    check_output(shlex.split('git checkout ' + branch),
                                 stderr=STDOUT,
                                 close_fds=True)
                except Exception as e:  # pragma: no cover
                    self.logger.error('repo_branches failed with error: ' +
                                      str(e) + ' on branch: ' + str(branch))
                    status = (False, e)
                    return status

            chdir(cwd)
            status = (True, branches)
        except Exception as e:  # pragma: no cover
            self.logger.error('repo_branches failed with error: ' + str(e))
            status = (False, e)

        return status
721834
def find_worktree_git_dir(dotgit):
    """"""
    try:
        statbuf = os.stat(dotgit)
    except OSError:
        return None
    if not stat.S_ISREG(statbuf.st_mode):
        return None

    try:
        lines = open(dotgit, 'r').readlines()
        for key, value in [line.strip().split(': ') for line in lines]:
            if key == 'gitdir':
                return value
    except ValueError:
        pass
    return None
1233021
def get_vcs_directory(context, directory):
        """"""
        nested = os.path.join(directory, '.git')
        return nested if context.is_directory(nested) else directory
1322
def get_root_folder():
    
    locations = {
     'linux':{'hme':'/home/duncan/', 'core_folder':'/home/duncan/dev/src/python/AIKIF'},
     'win32':{'hme':'T:\\user\\',    'core_folder':'T:\\user\\dev\\src\\python\\AIKIF'},
     'cygwin':{'hme':os.getcwd() + os.sep,    'core_folder':os.getcwd()},
     'darwin':{'hme':os.getcwd() + os.sep,    'core_folder':os.getcwd()}
    }
    hme = locations[sys.platform]['hme']
    core_folder = locations[sys.platform]['core_folder']

    if not os.path.exists(core_folder):
        hme = os.getcwd()        
        core_folder = os.getcwd()
        print('config.py : running on CI build (or you need to modify the paths in config.py)')
    return hme, core_folder
343201
def get_path_to_repo_and_branch(self, repo: str, branch: str) -> Path:
        
        return self.get_path_to_repo(repo).resolve() / branch
909893
def _git_repo_path(self):
        
        logger.debug('Checking for git directory in: %s', self._package_top_dir)
        for p in self._package_top_dir:
            gitdir = os.path.join(p, '.git')
            if os.path.exists(gitdir):
                logger.debug('_is_git_clone() true based on %s' % gitdir)
                return gitdir
        logger.debug('_is_git_clone() false')
        return None
403401
def get_path(self, repo):
        
        if repo.endswith('.git'):
            repo = repo.split('.git')[0]
        org, name = repo.split('/')[-2:]
        path = self.plugins_dir
        path = join(path, org, name)
        return path, org, name
1093398
def find_repo_root_by_path(path):
    """"""
    repo = git.Repo(path, search_parent_directories=True)
    repo_path = repo.git.rev_parse('--show-toplevel')
    logging.info('Repository: {}'.format(repo_path))
    return repo_path
527471
function getBowerFolder() {
    var bowerRC = getBowerRC();
    if (bowerRC === null || bowerRC.directory === undefined) {
        return 'bower_components';
    }

    return bowerRC.directory;
}
214342
def _mk_tree(runas='root'):
    '''
    
    '''
    basedir = tempfile.mkdtemp()
    paths = ['BUILD', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS']
    for path in paths:
        full = os.path.join(basedir, path)
        __salt__['file.makedirs_perms'](name=full, user=runas, group='mock')
    return basedir
1330868
def _find_file(self, path, saltenv='base'):
        '''
        
        '''
        fnd = {'path': '',
               'rel': ''}

        if salt.utils.url.is_escaped(path):
            # The path arguments are escaped
            path = salt.utils.url.unescape(path)
        for root in self.opts['pillar_roots'].get(saltenv, []):
            full = os.path.join(root, path)
            if os.path.isfile(full):
                fnd['path'] = full
                fnd['rel'] = path
                return fnd
        return fnd
1358575
def getRootDirectory(cls):
        
        if cls._is_running_on_worker:
            return cls._root_directory
        else:
            # This will have to change if we support multiple SparkContexts:
            return cls._sc._jvm.org.apache.spark.SparkFiles.getRootDirectory()
118004
def _get_cache_dir(self, commit_hash):
        
        path = os.path.join(self._path, commit_hash)
        stamp = path + ".timestamp"
        return path, stamp