Beispiel #1
0
func expandAlias(args *Args) {
	cmd := args.Command
	expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
	if err == nil && expandedCmd != "" {
		args.Command = expandedCmd
	}
}
Beispiel #2
0
func useHttpProtocol() bool {
	https := os.Getenv("GH_PROTOCOL")
	if https == "" {
		https, _ = git.Config("gh.protocol")
	}

	return https == "https"
}
Beispiel #3
0
func expandAlias(args *Args) {
	cmd := args.Command
	expandedCmd, err := git.Config(fmt.Sprintf("alias.%s", cmd))
	if err == nil && expandedCmd != "" {
		words, err := shellquote.Split(expandedCmd)
		if err != nil {
			args.Command = words[0]
			args.PrependParams(words[1:]...)
		}
	}
}
Beispiel #4
0
func knownHosts() (hosts Hosts) {
	ghHosts, _ := git.Config("gh.host")
	for _, ghHost := range strings.Split(ghHosts, "\n") {
		hosts = append(hosts, ghHost)
	}

	defaultHost := DefaultHost()
	hosts = append(hosts, defaultHost)
	hosts = append(hosts, fmt.Sprintf("ssh.%s", defaultHost))

	return
}
Beispiel #5
0
func (r *GitHubRepo) RemoteBranchAndProject(owner string) (branch *Branch, project *Project, err error) {
	project, err = r.MainProject()
	if err != nil {
		return
	}

	branch, err = r.CurrentBranch()
	if err != nil {
		return
	}

	pushDefault, _ := git.Config("push.default")
	if pushDefault == "upstream" || pushDefault == "tracking" {
		branch, err = branch.Upstream()
		if err != nil {
			return
		}
	} else {
		shortName := branch.ShortName()
		remotes := r.remotesForPublish(owner)
		for _, remote := range remotes {
			if git.HasFile("refs", "remotes", remote.Name, shortName) {
				name := fmt.Sprintf("refs/remotes/%s/%s", remote.Name, shortName)
				branch = &Branch{name}
				break
			}
		}
	}

	if branch.IsRemote() {
		remote, e := r.RemoteByName(branch.RemoteName())
		if e == nil {
			project, err = remote.Project()
			if err != nil {
				return
			}
		}
	}

	return
}