当前位置: 首页>>代码示例>>Golang>>正文


Golang Repository.GitRootDir方法代码示例

本文整理汇总了Golang中sourcegraph/com/sourcegraph/go-vcs/vcs.Repository.GitRootDir方法的典型用法代码示例。如果您正苦于以下问题:Golang Repository.GitRootDir方法的具体用法?Golang Repository.GitRootDir怎么用?Golang Repository.GitRootDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sourcegraph/com/sourcegraph/go-vcs/vcs.Repository的用法示例。


在下文中一共展示了Repository.GitRootDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CrossRepoMergeBase

func (r *Repository) CrossRepoMergeBase(a vcs.CommitID, repoB vcs.Repository, b vcs.CommitID) (vcs.CommitID, error) {
	// libgit2 Repository inherits GitRootDir and CrossRepo from its
	// embedded gitcmd.Repository.

	var repoBDir string // path to head repo on local filesystem
	if repoB, ok := repoB.(gitcmd.CrossRepo); ok {
		repoBDir = repoB.GitRootDir()
	} else {
		return "", fmt.Errorf("git cross-repo merge-base not supported against repo type %T", repoB)
	}

	if repoBDir == r.Dir {
		return r.MergeBase(a, b)
	}

	r.editLock.Lock()
	defer r.editLock.Unlock()

	rem, err := r.createAndFetchFromAnonRemote(repoBDir)
	if err != nil {
		return "", err
	}
	defer rem.Free()

	return r.mergeBaseHoldingEditLock(a, b)
}
开发者ID:shazow,项目名称:go-vcs,代码行数:26,代码来源:repo.go

示例2: CrossRepoDiff

func (r *Repository) CrossRepoDiff(base vcs.CommitID, headRepo vcs.Repository, head vcs.CommitID, opt *vcs.DiffOptions) (diff *vcs.Diff, err error) {
	// libgit2 Repository inherits GitRootDir and CrossRepo from its
	// embedded gitcmd.Repository.

	var headDir string // path to head repo on local filesystem
	if headRepo, ok := headRepo.(gitcmd.CrossRepo); ok {
		headDir = headRepo.GitRootDir()
	} else {
		return nil, fmt.Errorf("git cross-repo diff not supported against head repo type %T", headRepo)
	}

	if headDir == r.Dir {
		return r.Diff(base, head, opt)
	}

	r.editLock.Lock()
	defer r.editLock.Unlock()

	rem, err := r.createAndFetchFromAnonRemote(headDir)
	if err != nil {
		return nil, err
	}
	defer rem.Free()

	return r.diffHoldingEditLock(base, head, opt)
}
开发者ID:shazow,项目名称:go-vcs,代码行数:26,代码来源:repo.go

示例3: CrossRepoDiff

func (r *Repository) CrossRepoDiff(base vcs.CommitID, headRepo vcs.Repository, head vcs.CommitID, opt *vcs.DiffOptions) (*vcs.Diff, error) {
	var headDir string // path to head repo on local filesystem
	if headRepo, ok := headRepo.(CrossRepo); ok {
		headDir = headRepo.GitRootDir()
	} else {
		return nil, fmt.Errorf("git cross-repo diff not supported against head repo type %T", headRepo)
	}

	if headDir == r.Dir {
		return r.Diff(base, head, opt)
	}

	if err := r.fetchRemote(headDir); err != nil {
		return nil, err
	}

	return r.Diff(base, head, opt)
}
开发者ID:emil2k,项目名称:go-vcs,代码行数:18,代码来源:repo.go

示例4: CrossRepoMergeBase

func (r *Repository) CrossRepoMergeBase(a vcs.CommitID, repoB vcs.Repository, b vcs.CommitID) (vcs.CommitID, error) {
	// git.Repository inherits GitRootDir and CrossRepo from its
	// embedded gitcmd.Repository.

	var repoBDir string // path to head repo on local filesystem
	if repoB, ok := repoB.(CrossRepo); ok {
		repoBDir = repoB.GitRootDir()
	} else {
		return "", fmt.Errorf("git cross-repo merge-base not supported against repo type %T", repoB)
	}

	if repoBDir != r.Dir {
		if err := r.fetchRemote(repoBDir); err != nil {
			return "", err
		}
	}

	return r.MergeBase(a, b)
}
开发者ID:emil2k,项目名称:go-vcs,代码行数:19,代码来源:repo.go


注:本文中的sourcegraph/com/sourcegraph/go-vcs/vcs.Repository.GitRootDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。