Helper to retrieve git config options
549001
def _git_config(cwd, user, password, output_encoding=None):
    '''
    
    '''
    contextkey = 'git.config.' + cwd
    if contextkey not in __context__:
        git_dir = rev_parse(cwd,
                            opts=['--git-dir'],
                            user=user,
                            password=password,
                            ignore_retcode=True,
                            output_encoding=output_encoding)
        if not os.path.isabs(git_dir):
            paths = (cwd, git_dir, 'config')
        else:
            paths = (git_dir, 'config')
        __context__[contextkey] = os.path.join(*paths)
    return __context__[contextkey]
210171
public function getConfig($prefix = null)
    {
        $data = [];
        $len  = strlen($prefix);

        foreach ($this->sys->exec('git config -l', 'Unable to retrieve git config') as $row) {
            list ($key, $value) = explode('=', $row, 2);

            if (null !== $prefix) {
                if (substr($key, 0, $len) !== $prefix) {
                    continue;
                }

                $key = substr($key, $len);
            }

            $data[$key] = $value;
        }

        return $data;
    }
509907
def _get_branch_opts(branch, local_branch, all_local_branches,
                     desired_upstream, git_ver=None):
    '''
    
    '''
    if branch is not None and branch not in all_local_branches:
        # We won't be setting upstream because the act of checking out a new
        # branch will set upstream for us
        return None

    if git_ver is None:
        git_ver = _LooseVersion(__salt__['git.version'](versioninfo=False))

    ret = []
    if git_ver >= _LooseVersion('1.8.0'):
        ret.extend(['--set-upstream-to', desired_upstream])
    else:
        ret.append('--set-upstream')
        # --set-upstream does not assume the current branch, so we have to
        # tell it which branch we'll be using
        ret.append(local_branch if branch is None else branch)
        ret.append(desired_upstream)
    return ret
38704
def get(self, section, option, as_list=False):
        '''
        
        '''
        ret = super(GitConfigParser, self).get(section, option)
        if as_list and not isinstance(ret, list):
            ret = [ret]
        return ret
797019
def git_repos(options = {})
      ensure_ready!(:authorization)
      response = connection.get(git_repo_path, options)
      checked_response_body(response)
    end
170057
def guess_gitflow_config(dir = Dir.pwd, options = {})
      path = normalized_path(dir)
      use_git = FalkorLib::Git.init?(path)
      return {} if (!use_git or !FalkorLib::GitFlow.init?(path))
      rootdir = FalkorLib::Git.rootdir(path)
      local_config = FalkorLib::Config.get(rootdir, :local)
      return local_config[:gitflow] if local_config[:gitflow]
      config = FalkorLib::Config::GitFlow::DEFAULTS.clone
      [ :master, :develop ].each do |br|
        config[:branches][br.to_sym] = FalkorLib::Git.config("gitflow.branch.#{br}", rootdir)
      end
      [ :feature, :release, :hotfix, :support, :versiontag ].each do |p|
        config[:prefix][p.to_sym] = FalkorLib::Git.config("gitflow.prefix.#{p}", rootdir)
      end
      config
    end
1119923
def getConf(cls, settings, options):
        ""
        ports = ['http_port', 'https_port', 'cache_port']
        for port_name in ports:
            port = getattr(settings, port_name.upper(), None)
            # only use the settings ports if the defaults were left unchanged
            default = getattr(defaults, port_name.upper())
            if port and options.get(port_name) == default:
                options[port_name] = port

        _opts = [
            ('key', 'hx_private_key'),
            ('cert', 'hx_certficate'),
            ('wsgi', 'wsgi_application')
        ]
        for opt_name, settings_name in _opts:
            opt = getattr(settings, settings_name.upper(), None)
            if opt:
                options[opt_name] = opt

        if not options['settings']:
            options['settings'] = environ['DJANGO_SETTINGS_MODULE']
        return options
628500
def get_configuration_dict(self, secret_attrs=False):
        """"""
        rd = {'name': self.name,
              'path': self.path,
              'git_dir': self.git_dir,
              'assumed_doc_version': self.assumed_doc_version,
              'doc_dir': self.doc_dir,
              'git_ssh': self.git_ssh, }
        if secret_attrs:
            rd['pkey'] = self.pkey
        with self._index_lock:
            si = self._doc_index
        r = _invert_dict_list_val(si)
        key_list = list(r.keys())
        rd['number of documents'] = len(key_list)
        key_list.sort()
        m = []
        for k in key_list:
            v = r[k]
            fp = k[2]
            assert fp.startswith(self.doc_dir)
            rp = fp[len(self.doc_dir) + 1:]
            m.append({'keys': v, 'relpath': rp})
        rd['documents'] = m
        return rd
381823
def update_configs(self, release):
        
        git_repo = release['git_repo']
        git_cache = release['git_cache']
        if not os.path.isdir(git_cache):
            self.call(['git', 'clone', '--mirror', git_repo, git_cache])
        else:
            self.call(['git', 'fetch', '--all', '--prune'], cwd=git_cache)
        git_dir = release['git_dir'] = os.path.join(release['tmp_dir'],
                                                    os.path.basename(git_repo))
        self.call(['git', 'clone', '-b', release['git_branch'],
                   git_cache, git_dir])

        if release['delete_repo_files']:
            for repo_file in glob.glob(os.path.join(git_dir, '*.repo')):
                self.log.info('Deleting %s' % repo_file)
                os.unlink(repo_file)
78626
def parse_options(settings):
    ''''''
    optlist, args = getopt(sys.argv, 'x', [])
    settings['configfile'] = args[1]
    return settings
665934
def init_config!(config)
      set_internal_config!(config)
      config.each do |(directory, git_repos)|
        git_repos.each do |git_repo|
          git_repo         = git_repo.include?("github.com") ? git_repo : "https://github.com/#{git_repo}.git"
          repo_name        = name_from_git_repo(git_repo)
          repo_path        = File.join(repo_directory_path, directory, repo_name)
          if repos.key? repo_name
            puts "  warning duplicate repo found: #{repo_name.inspect}"
            repos[repo_name] = false
          else
            repos[repo_name] = repo_path
          end
          dirs[repo_path]  = git_repo
        end
      end
    end
1021186
def enforce_git_config(self):
        '''
        
        '''
        git_config = os.path.join(self.gitdir, 'config')
        conf = salt.utils.configparser.GitConfigParser()
        if not conf.read(git_config):
            log.error('Failed to read from git config file %s', git_config)
        else:
            # We are currently enforcing the following git config items:
            # 1. Fetch URL
            # 2. refspecs used in fetch
            # 3. http.sslVerify
            conf_changed = False
            remote_section = 'remote "origin"'

            # 1. URL
            try:
                url = conf.get(remote_section, 'url')
            except salt.utils.configparser.NoSectionError:
                # First time we've init'ed this repo, we need to add the
                # section for the remote to the git config
                conf.add_section(remote_section)
                conf_changed = True
                url = None
            log.debug(
                'Current fetch URL for %s remote \'%s\': %s (desired: %s)',
                self.role, self.id, url, self.url
            )
            if url != self.url:
                conf.set(remote_section, 'url', self.url)
                log.debug(
                    'Fetch URL for %s remote \'%s\' set to %s',
                    self.role, self.id, self.url
                )
                conf_changed = True

            # 2. refspecs
            try:
                refspecs = sorted(
                    conf.get(remote_section, 'fetch', as_list=True))
            except salt.utils.configparser.NoOptionError:
                # No 'fetch' option present in the remote section. Should never
                # happen, but if it does for some reason, don't let it cause a
                # traceback.
                refspecs = []
            desired_refspecs = sorted(self.refspecs)
            log.debug(
                'Current refspecs for %s remote \'%s\': %s (desired: %s)',
                self.role, self.id, refspecs, desired_refspecs
            )
            if refspecs != desired_refspecs:
                conf.set_multivar(remote_section, 'fetch', self.refspecs)
                log.debug(
                    'Refspecs for %s remote \'%s\' set to %s',
                    self.role, self.id, desired_refspecs
                )
                conf_changed = True

            # 3. http.sslVerify
            try:
                ssl_verify = conf.get('http', 'sslVerify')
            except salt.utils.configparser.NoSectionError:
                conf.add_section('http')
                ssl_verify = None
            except salt.utils.configparser.NoOptionError:
                ssl_verify = None
            desired_ssl_verify = six.text_type(self.ssl_verify).lower()
            log.debug(
                'Current http.sslVerify for %s remote \'%s\': %s (desired: %s)',
                self.role, self.id, ssl_verify, desired_ssl_verify
            )
            if ssl_verify != desired_ssl_verify:
                conf.set('http', 'sslVerify', desired_ssl_verify)
                log.debug(
                    'http.sslVerify for %s remote \'%s\' set to %s',
                    self.role, self.id, desired_ssl_verify
                )
                conf_changed = True

            # Write changes, if necessary
            if conf_changed:
                with salt.utils.files.fopen(git_config, 'w') as fp_:
                    conf.write(fp_)
                    log.debug(
                        'Config updates for %s remote \'%s\' written to %s',
                        self.role, self.id, git_config
                    )
1261316
def get_config(repo):
    
    files = get_files(repo)
    config = DEFAULT_CONFIG
    if "config.json" in files:
        # get the config file, parse JSON and merge it with the default config
        config_file = repo.get_file_contents('/config.json', ref="gh-pages")
        try:
            repo_config = json.loads(config_file.decoded_content.decode("utf-8"))
            config.update(repo_config)
        except ValueError:
            click.secho("WARNING: Unable to parse config file. Using defaults.", fg="yellow")
    return config
321253
def get_options():
    """"""
    options = collections.defaultdict(list)
    for opt_class in config_factory.get_options():
        if not issubclass(opt_class, config_base.Options):
            continue
        config_options = opt_class(None)
        options[config_options.group_name].extend(config_options.list())
    return [(key, value) for key, value in options.items()]
75941
def _get_config():
    '''
    
    '''
    cfg = os.path.expanduser('~/.dockercfg')
    try:
        fic = open(cfg)
        try:
            config = json.loads(fic.read())
        finally:
            fic.close()
    except Exception:
        config = {'rootPath': '/dev/null'}
    if not 'Configs' in config:
        config['Configs'] = {}
    return config
1301237
def guess_project_config(dir = Dir.pwd, options = {})
      path = normalized_path(dir)
      use_git = FalkorLib::Git.init?(path)
      rootdir = (use_git) ? FalkorLib::Git.rootdir(path) : path
      local_config = FalkorLib::Config.get(rootdir, :local)
      return local_config[:project] if local_config[:project]
      # Otherwise, guess the rest of the configuration
      config = FalkorLib::Config::Bootstrap::DEFAULTS[:metadata].clone
      # Apply options (if provided)
      [ :name, :forge ].each do |k|
        config[k.to_sym] = options[k.to_sym] if options[k.to_sym]
      end
      config[:name] = ask("\tProject name: ", get_project_name(dir)) if config[:name].empty?
      if (use_git)
        config[:origin] = FalkorLib::Git.config('remote.origin.url')
        if config[:origin] =~ /((gforge|gitlab|github)[\.\w_-]+)[:\d\/]+(\w*)/
          config[:forge] = Regexp.last_match(2).to_sym
          config[:by]    = Regexp.last_match(3)
        elsif config[:forge].empty?
          config[:forge] = select_forge(config[:forge]).to_sym
        end
      end
      forges = FalkorLib::Config::Bootstrap::DEFAULTS[:forge][ config[:forge].to_sym ]
      default_source = case config[:forge]
                       when :gforge
                         'https://' + forges[:url] + "/projects/" + config[:name].downcase
                       when :github, :gitlab
                         'https://' + forges[:url] + "/" + config[:by] + "/" + config[:name].downcase
                       else
                         ""
                       end
      config[:source] = config[:project_page] = default_source
      config[:issues_url] =  "#{config[:project_page]}/issues"
      config[:license] = select_licence if config[:license].empty?
      [ :summary  ].each do |k|
        config[k.to_sym] = ask( "\t" + Kernel.format("Project %-20s", k.to_s))
      end
      config[:description] = config[:summary]
      config[:gitflow] = FalkorLib::GitFlow.guess_gitflow_config(rootdir)
      config[:make] = File.exists?(File.join(rootdir, 'Makefile'))
      config[:rake] = File.exists?(File.join(rootdir, 'Rakefile'))
      config
    end
620126
function getConfigOptions(opts) {
    opts = formatOptions(opts);
    _.forEach(config, function(value, key) {
      opts[key] = opts[key] || value;
    });
    opts.headers = opts.headers || {};

    return opts;
  }