示例#1
0
文件: util.go 项目: ZBNA/deploy
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
文件: branch.go 项目: ZBNA/deploy
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
文件: project.go 项目: ZBNA/deploy
func useHttpProtocol() bool {
	https := os.Getenv("HUB_PROTOCOL")
	if https == "" {
		https, _ = git.Config("hub.protocol")
	}

	return https == "https"
}
示例#4
0
文件: hosts.go 项目: ZBNA/deploy
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
}