Пример #1
0
func IsHttpsProtocol() bool {
	httpProcotol, _ := git.Config("hub.protocol")
	if httpProcotol == "https" {
		return true
	}

	httpClone, _ := git.Config("--bool hub.http-clone")
	if httpClone == "true" {
		return true
	}

	return false
}
Пример #2
0
func (b *Branch) PushTarget(owner string, preferUpstream bool) (branch *Branch) {
	var err error
	pushDefault, _ := git.Config("push.default")
	if pushDefault == "upstream" || pushDefault == "tracking" {
		branch, err = b.Upstream()
		if err != nil {
			return
		}
	} else {
		shortName := b.ShortName()
		remotes := b.Repo.remotesForPublish(owner)

		var remotesInOrder []Remote
		if preferUpstream {
			// reverse the remote lookup order
			// see OriginNamesInLookupOrder
			for i := len(remotes) - 1; i >= 0; i-- {
				remotesInOrder = append(remotesInOrder, remotes[i])
			}
		} else {
			remotesInOrder = remotes
		}

		for _, remote := range remotesInOrder {
			if git.HasFile("refs", "remotes", remote.Name, shortName) {
				name := fmt.Sprintf("refs/remotes/%s/%s", remote.Name, shortName)
				branch = &Branch{b.Repo, name}
				break
			}
		}
	}

	return
}
Пример #3
0
func useHttpProtocol() bool {
	https := os.Getenv("HUB_PROTOCOL")
	if https == "" {
		https, _ = git.Config("hub.protocol")
	}

	return https == "https"
}
Пример #4
0
func knownGitHubHosts() (hosts GitHubHosts) {
	defaultHost := DefaultGitHubHost()
	hosts = append(hosts, defaultHost)
	hosts = append(hosts, "ssh."+GitHubHost)

	ghHosts, _ := git.Config("hub.host")
	for _, ghHost := range strings.Split(ghHosts, "\n") {
		ghHost = strings.TrimSpace(ghHost)
		if ghHosts != "" {
			hosts = append(hosts, ghHost)
		}
	}

	return
}