// ReadWriteURL formats the git ssh url and return it. If no remote is configured in
// gandalf.conf, this method panics.
769956
func (r *Repository) ReadWriteURL() string {
	uid, err := config.GetString("uid")
	if err != nil {
		panic(err.Error())
	}
	remote := uid + "@%s:%s.git"
	if useSSH, _ := config.GetBool("git:ssh:use"); useSSH {
		var port string
		port, err = config.GetString("git:ssh:port")
		if err == nil {
			remote = "ssh://" + uid + "@%s:" + port + "/%s.git"
		} else {
			remote = "ssh://" + uid + "@%s/%s.git"
		}
	}
	host, err := config.GetString("host")
	if err != nil {
		panic(err.Error())
	}
	return fmt.Sprintf(remote, host, r.Name)
}
1120063
func (r *RepositoryRelease) GetURL() string {
	if r == nil || r.URL == nil {
		return ""
	}
	return *r.URL
}
772594
func FetchURL(source string, timeout time.Duration) (io.ReadCloser, error) {
	resp, err := httpGet(source, timeout)
	if err != nil {
		return nil, fmt.Errorf("http fetch %s: %v", source, err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("server response: %s", resp.Status)
	}

	return resp.Body, nil
}
622635
func (c *Commit) GetURL() string {
	if c == nil || c.URL == nil {
		return ""
	}
	return *c.URL
}
322166
func ReadVarUint32(r io.Reader) (uint32, error) {
	u64, err := ReadVarUint64(r)
	if err != nil {
		return 0, err
	}
	return uint32(u64), nil
}
501500
func (i *Installation) GetRepositoriesURL() string {
	if i == nil || i.RepositoriesURL == nil {
		return ""
	}
	return *i.RepositoriesURL
}
922371
func (g *Git) ReadDir(revision, path string) ([]os.FileInfo, error) {
	if revision == revisionFS {
		return ioutil.ReadDir(path)
	}

	relPath, err := g.rel(path)
	if err != nil {
		return nil, err
	}
	relPath += string(os.PathSeparator)

	args := []string{"--git-dir", g.dir, "ls-tree", revision, relPath}
	ls, err := exec.Command("git", args...).CombinedOutput()
	if err != nil {
		return nil, fmt.Errorf("could not execute git %v, error: %s", args, err)
	}

	var files []os.FileInfo
	for _, file := range bytes.Split(ls, []byte{'\n'}) {
		// 100644 blob 78edbf3fb411055b4a3d4d3d137ccbec160ac956    .gitignore
		// 040000 tree e62f2cac29e1d6e31aeac65ded75df98b9c1be43    testdata
		fields := bytes.Fields(file)
		if len(fields) != 4 {
			continue
		}

		files = append(files, fileInfo{
			// name is basename (no directory structure)
			name: strings.TrimPrefix(string(fields[3]), relPath),
			dir:  bytes.Equal(fields[1], []byte("tree")),
		})
	}
	return files, nil
}
930412
func formatURL(protocol string, addr net.Listener) []string {
	hostports := resolveHostPorts(addr)
	for i, hp := range hostports {
		hostports[i] = fmt.Sprintf("%s://%s", protocol, hp)
	}
	return hostports
}
407381
func (s *SourceRevision) SetRevisionUrl(v string) *SourceRevision {
	s.RevisionUrl = &v
	return s
}
660868
func CopyURL(i *url.URL) *url.URL {
	out := *i
	if i.User != nil {
		out.User = &(*i.User)
	}
	return &out
}
1233470
func copyURL(i *url.URL) *url.URL {
	out := *i
	if i.User != nil {
		out.User = &(*i.User)
	}
	return &out
}
239141
func ConvertURL(input io.Reader, readability bool) (string, map[string]string, error) {
	meta := make(map[string]string)

	buf := new(bytes.Buffer)
	_, err := buf.ReadFrom(input)
	if err != nil {
		return "", nil, err
	}

	g := goose.New()
	article, err := g.ExtractFromURL(buf.String())
	if err != nil {
		return "", nil, err
	}

	meta["title"] = article.Title
	meta["description"] = article.MetaDescription
	meta["image"] = article.TopImage

	return article.CleanedText, meta, nil
}
1053847
func ParseUpstreamURL() (owner, repo string, err error) {
	// Load the Git config.
	gitConfig, err := git.LoadConfig()
	if err != nil {
		return "", "", err
	}
	remoteName := gitConfig.RemoteName

	// Get the upstream URL.
	task := fmt.Sprintf("Get URL for git remote '%v'", remoteName)
	remoteURL, err := git.GetConfigString(fmt.Sprintf("remote.%v.url", remoteName))
	if err != nil {
		return "", "", errs.NewError(task, err)
	}

	// Parse it and return the result.
	return parseUpstreamURL(remoteURL)
}
716509
func (c *Commit) GetHTMLURL() string {
	if c == nil || c.HTMLURL == nil {
		return ""
	}
	return *c.HTMLURL
}
376394
func ComposeHTTPSCloneURL(owner, repo string) string {
	return fmt.Sprintf("%s%s/%s.git", setting.AppURL, owner, repo)
}
28312
func (reader PluginConfigReaderWithError) GetURL(key string, defaultValue string) (*url.URL, error) {
	value, err := reader.GetString(key, defaultValue)
	if err != nil {
		return nil, err
	}
	if value == "" {
		return nil, nil
	}
	urlValue, err := url.Parse(value)
	if err != nil {
		return nil, err
	}
	return urlValue, nil
}
598294
func (w *wizard) readURL() *url.URL {
	for {
		fmt.Printf("> ")
		text, err := w.in.ReadString('\n')
		if err != nil {
			log.Crit("Failed to read user input", "err", err)
		}
		uri, err := url.Parse(strings.TrimSpace(text))
		if err != nil {
			log.Error("Invalid input, expected URL", "err", err)
			continue
		}
		return uri
	}
}