當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Project.GitURL方法代碼示例

本文整理匯總了Golang中github.com/jingweno/gh/github.Project.GitURL方法的典型用法代碼示例。如果您正苦於以下問題:Golang Project.GitURL方法的具體用法?Golang Project.GitURL怎麽用?Golang Project.GitURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/jingweno/gh/github.Project的用法示例。


在下文中一共展示了Project.GitURL方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: transformRemoteArgs

func transformRemoteArgs(args *Args) {
	ownerWithName := args.LastParam()
	owner, name, match := parseRepoNameOwner(ownerWithName)
	if !match {
		return
	}

	var err error
	if name == "" {
		name, err = utils.DirName()
		utils.Check(err)
	}

	isPriavte := parseRemotePrivateFlag(args)

	if owner == "origin" {
		owner = github.CurrentConfig().FetchUser()
	} else if args.ParamsSize() > 2 {
		// `git remote add jingweno foo/bar`
		args.RemoveParam(args.ParamsSize() - 1)
	}

	project := github.Project{Owner: owner, Name: name}
	url := project.GitURL(name, owner, isPriavte)

	args.AppendParams(url)
}
開發者ID:johnbellone,項目名稱:gh,代碼行數:27,代碼來源:remote.go

示例2: transformCloneArgs

func transformCloneArgs(args *Args) {
	isSSH := parseClonePrivateFlag(args)
	hasValueRegxp := regexp.MustCompile("^(--(upload-pack|template|depth|origin|branch|reference|name)|-[ubo])$")
	nameWithOwnerRegexp := regexp.MustCompile(NameWithOwnerRe)
	for i, a := range args.Params {
		if hasValueRegxp.MatchString(a) {
			continue
		}

		if nameWithOwnerRegexp.MatchString(a) && !isDir(a) {
			name, owner := parseCloneNameAndOwner(a)
			config := github.CurrentConfig()
			isSSH = isSSH || owner == config.User
			if owner == "" {
				owner = config.User
			}

			project := github.Project{Name: name, Owner: owner}
			url := project.GitURL(name, owner, isSSH)
			args.ReplaceParam(i, url)

			break
		}
	}
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:25,代碼來源:clone.go

示例3: transformInitArgs

func transformInitArgs(args *Args) error {
	if !parseInitFlag(args) {
		return nil
	}

	name, err := utils.DirName()
	if err != nil {
		return err
	}

	owner := github.CurrentConfig().FetchUser()
	project := github.Project{Owner: owner, Name: name}
	url := project.GitURL(name, owner, true)
	args.After("git", "remote", "add", "origin", url)

	return nil
}
開發者ID:rif,項目名稱:golang-stuff,代碼行數:17,代碼來源:init.go

示例4: transformCloneArgs

func transformCloneArgs(args *Args) {
	isSSH := parseClonePrivateFlag(args)
	hasValueRegxp := regexp.MustCompile("^(--(upload-pack|template|depth|origin|branch|reference|name)|-[ubo])$")
	nameWithOwnerRegexp := regexp.MustCompile(NameWithOwnerRe)
	var skipNext bool
	for i, a := range args.Params {
		if skipNext {
			skipNext = false
			continue
		}

		if strings.HasPrefix(a, "-") {
			if hasValueRegxp.MatchString(a) {
				skipNext = true
			}
			continue
		}

		if github.MatchURL(a) != nil {
			break
		}

		if nameWithOwnerRegexp.MatchString(a) && !isDir(a) {
			name, owner := parseCloneNameAndOwner(a)
			config := github.CurrentConfig()
			isSSH = isSSH || args.Command != "submodule" && owner == config.User
			if owner == "" {
				owner = config.User
				isSSH = true
			}

			project := github.Project{Name: name, Owner: owner}
			url := project.GitURL(name, owner, isSSH)
			args.ReplaceParam(i, url)

			break
		}
	}
}
開發者ID:johnbellone,項目名稱:gh,代碼行數:39,代碼來源:clone.go


注:本文中的github.com/jingweno/gh/github.Project.GitURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。