本文整理汇总了Golang中github.com/jingweno/gh/github.Branch.ShortName方法的典型用法代码示例。如果您正苦于以下问题:Golang Branch.ShortName方法的具体用法?Golang Branch.ShortName怎么用?Golang Branch.ShortName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/jingweno/gh/github.Branch
的用法示例。
在下文中一共展示了Branch.ShortName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: branchInURL
func branchInURL(branch *github.Branch) string {
parts := strings.Split(branch.ShortName(), "/")
newPath := make([]string, len(parts))
for i, s := range parts {
newPath[i] = url.QueryEscape(s)
}
return strings.Join(newPath, "/")
}
示例2: compare
/*
$ gh compare refactor
> open https://github.com/CURRENT_REPO/compare/refactor
$ gh compare 1.0..1.1
> open https://github.com/CURRENT_REPO/compare/1.0...1.1
$ gh compare -u other-user patch
> open https://github.com/other-user/REPO/compare/patch
*/
func compare(command *Command, args *Args) {
localRepo := github.LocalRepo()
var (
branch *github.Branch
project *github.Project
r string
err error
)
branch, project, err = localRepo.RemoteBranchAndProject("")
utils.Check(err)
if args.IsParamsEmpty() {
master := localRepo.MasterBranch()
if master.ShortName() == branch.ShortName() {
err = fmt.Errorf(command.FormattedUsage())
utils.Check(err)
} else {
r = branch.ShortName()
}
} else {
r = parseCompareRange(args.RemoveParam(args.ParamsSize() - 1))
if args.IsParamsEmpty() {
project, err = localRepo.CurrentProject()
utils.Check(err)
} else {
project = github.NewProject(args.RemoveParam(args.ParamsSize()-1), "", "")
}
}
r = strings.Replace(r, "/", ";", -1)
subpage := utils.ConcatPaths("compare", r)
url := project.WebURL("", "", subpage)
launcher, err := utils.BrowserLauncher()
utils.Check(err)
if flagCompareURLOnly {
args.Replace("echo", url)
} else {
args.Replace(launcher[0], "", launcher[1:]...)
args.AppendParams(url)
}
}