Determine the primary remote url for this Repository

        Returns:
            str: primary remote url for this Repository
                (``git config remote.origin.url``)
557979
def remote_url(self, remotename='origin'):
        
        cmd = ['git', 'config', 'remote.%s.url' % remotename]
        return self.sh(cmd, shell=False,
                       ignore_error=True).strip()
1158250
def origin(hosts):
    

    hosts = [urlsplit(h) for h in hosts]

    def func(environ):
        if 'ISSO_CORS_ORIGIN' in environ:
            return environ['ISSO_CORS_ORIGIN']

        if not hosts:
            return "http://invalid.local"

        loc = environ.get("HTTP_ORIGIN", environ.get("HTTP_REFERER", None))

        if loc is None:
            return urljoin(*hosts[0])

        for split in hosts:
            if urlsplit(loc) == split:
                return urljoin(*split)
        else:
            return urljoin(*hosts[0])

    return func
9432
def getback(config, force=False):
    """"""
    repo = config.repo

    active_branch = repo.active_branch
    if active_branch.name == "master":
        error_out("You're already on the master branch.")

    if repo.is_dirty():
        error_out(
            'Repo is "dirty". ({})'.format(
                ", ".join([repr(x.b_path) for x in repo.index.diff(None)])
            )
        )

    branch_name = active_branch.name

    state = read(config.configfile)
    origin_name = state.get("ORIGIN_NAME", "origin")
    upstream_remote = None
    fork_remote = None
    for remote in repo.remotes:
        if remote.name == origin_name:
            # remote.pull()
            upstream_remote = remote
            break
    if not upstream_remote:
        error_out("No remote called {!r} found".format(origin_name))

    # Check out master
    repo.heads.master.checkout()
    upstream_remote.pull(repo.heads.master)

    # Is this one of the merged branches?!
    # XXX I don't know how to do this "natively" with GitPython.
    merged_branches = [
        x.strip()
        for x in repo.git.branch("--merged").splitlines()
        if x.strip() and not x.strip().startswith("*")
    ]
    was_merged = branch_name in merged_branches
    certain = was_merged or force
    if not certain:
        # Need to ask the user.
        # XXX This is where we could get smart and compare this branch
        # with the master.
        certain = (
            input("Are you certain {} is actually merged? [Y/n] ".format(branch_name))
            .lower()
            .strip()
            != "n"
        )
    if not certain:
        return 1

    if was_merged:
        repo.git.branch("-d", branch_name)
    else:
        repo.git.branch("-D", branch_name)

    fork_remote = None
    for remote in repo.remotes:
        if remote.name == state.get("FORK_NAME"):
            fork_remote = remote
            break
    if fork_remote:
        fork_remote.push(":" + branch_name)
        info_out("Remote branch on fork deleted too.")
879045
def known_remotes(self):
        """"""
        objects = []
        for line in self.context.capture('git', 'remote', '--verbose').splitlines():
            tokens = line.split()
            if len(tokens) >= 2:
                name = tokens[0]
                objects.append(Remote(
                    default=(name == 'origin'),
                    location=tokens[1], name=name, repository=self,
                    # We fall back to allowing both roles when we fail to
                    # recognize either role because:
                    #
                    #  1. This code is relatively new and may be buggy.
                    #  2. Practically speaking most git repositories will use
                    #     the same remote for pushing and pulling and in fact
                    #     this remote is likely to be the only remote :-).
                    roles=(['pull'] if '(fetch)' in tokens
                           else (['push'] if '(push)' in tokens
                           else (['push', 'pull']))),
                ))
        return objects
839886
def _get_repo_file_url(namespace, filename):
    
    return '{base_url}{namespace}/{filename}'.format(base_url=_get_repo_url(),
                                                     namespace=namespace,
                                                     filename=filename)
1048154
def _get_remote(self, cached=True):
        '''
        
        '''

        return self.m(
            'getting current remote',
            cmdd=dict(
                cmd='git remote show %s' % ('-n' if cached else ''),
                cwd=self.local
            ),
            verbose=False
        )
804880
def get_commit_url(repo_url):
    """"""
    if "github.com" in repo_url:
        return repo_url[:-4] if repo_url.endswith(".git") else repo_url
    if "git.openstack.org" in repo_url:
        uri = '/'.join(repo_url.split('/')[-2:])
        return "https://github.com/{0}".format(uri)

    # If it didn't match these conditions, just return it.
    return repo_url
1151586
def _fetch(self):
        '''
        
        '''
        origin = self.repo.remotes[0]
        try:
            fetch_results = origin.fetch()
        except AssertionError:
            fetch_results = origin.fetch()

        new_objs = False
        for fetchinfo in fetch_results:
            if fetchinfo.old_commit is not None:
                log.debug(
                    '%s has updated \'%s\' for remote \'%s\' '
                    'from %s to %s',
                    self.role,
                    fetchinfo.name,
                    self.id,
                    fetchinfo.old_commit.hexsha[:7],
                    fetchinfo.commit.hexsha[:7]
                )
                new_objs = True
            elif fetchinfo.flags in (fetchinfo.NEW_TAG,
                                     fetchinfo.NEW_HEAD):
                log.debug(
                    '%s has fetched new %s \'%s\' for remote \'%s\'',
                    self.role,
                    'tag' if fetchinfo.flags == fetchinfo.NEW_TAG else 'head',
                    fetchinfo.name,
                    self.id
                )
                new_objs = True

        cleaned = self.clean_stale_refs()
        return True if (new_objs or cleaned) else None
636102
def check_repository_url(self):
        
        repository_url = self.repository_config['repository']

        if repository_url.startswith((repository.LEGACY_PYPI,
                                      repository.LEGACY_TEST_PYPI)):
            raise exceptions.UploadToDeprecatedPyPIDetected.from_args(
                repository_url,
                utils.DEFAULT_REPOSITORY,
                utils.TEST_REPOSITORY
            )
777768
def get_url(self):
        # type: () -> STRING_TYPE
        """"""

        line = self.line
        try:
            parsed = URI.parse(line)
            line = parsed.to_string(escape_password=False, direct=False, strip_ref=True)
        except ValueError:
            pass
        else:
            self._parsed_url = parsed
            return line
        if self.vcs is not None and self.line.startswith("{0}+".format(self.vcs)):
            _, _, _parseable = self.line.partition("+")
            parsed = urllib_parse.urlparse(add_ssh_scheme_to_git_uri(_parseable))
            line, _ = split_ref_from_uri(line)
        else:
            parsed = urllib_parse.urlparse(add_ssh_scheme_to_git_uri(line))
        if "@" in self.line and parsed.scheme == "":
            name, _, url = self.line.partition("@")
            if self._name is None:
                url = url.strip()
                self._name = name.strip()
                if is_valid_url(url):
                    self.is_direct_url = True
            line = url.strip()
            parsed = urllib_parse.urlparse(line)
            url_path = parsed.path
            if "@" in url_path:
                url_path, _, _ = url_path.rpartition("@")
            parsed = parsed._replace(path=url_path)
        self._parsed_url = parsed
        return line
938314
def repo_name
      unless @repo_name
        url = config["remote.#{name}.url"]
        raise GitProcessError.new("There is no #{name} url set up.") if url.nil? or url.empty?
        uri = Addressable::URI.parse(url)
        @repo_name = uri.path.sub(/\.git/, '').sub(/^\//, '')
      end
      @repo_name
    end
1320716
def absolute_url(self):
        
        if self.is_root():
            return utils.concat_urls(self.url)
        return utils.concat_urls(self.parent.absolute_url, self.url)
975104
def origin(self):
        
        for item in os.popen('git remote -v'):
            split_item = item.strip().split()
            if split_item[0] == 'origin' and split_item[-1] == '(push)':
                return split_item[1]
1133209
def remotes_with_urls
      result = {}
      git_call('remote -vv').split("\n").each do |line|
        entries = line.split("\t")
        remote = entries.first
        target_entry = entries.last.split(' ')
        direction = target_entry.last[1..-2].to_sym
        target_url = target_entry.first
        result[remote] ||= {}
        result[remote][direction] = target_url
      end
      result
    end
103578
def remote_url(self):
        
        cmd = 'svn info | grep "^Repository Root:"'
        return (
            self.sh(cmd, shell=True).split(': ', 1)[1]).strip()
3873
public function getRemoteUrl() {
		try {
			$values = $this->extractFromCommand ( 'git config --get remote.origin.url', function ($str) {
				return trim ( $str );
			} );
			if (isset ( $values )) {
				return implode ( " ", $values );
			}
		} catch ( \Cz\Git\GitException $e ) {
			return "";
		}
		return "";
	}
837728
def basename(url):
    
    # It's easy to accidentally have whitespace on the beginning or end of the
    # url.
    url = url.strip()

    url, _sep, _fragment = url.partition('#')
    # Remove trailing slash from url if present
    if url.endswith('/'):
        url = url[:-1]
    # Also strip .git from url if it ends in that.
    return re.sub(r'\.git$', '', url.split('/')[-1])