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


Golang Repository.Path方法代码示例

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


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

示例1: Init

func Init(repo *libgit.Repository, args []string) {
	if len(args) > 0 {
		if dir := args[len(args)-1]; dir != "init" {
			err := os.MkdirAll(dir, 0755)
			if err != nil {
				panic("Couldn't create directory for initializing git.")
			}
			err = os.Chdir(dir)
			if err != nil {
				panic("Couldn't change working directory while initializing git.")
			}
			if repo != nil {
				repo.Path = ".git/"
			}
		}
	}
	// These are all the directories created by a clean "git init"
	// with the canonical git implementation
	os.Mkdir(".git", 0755)
	os.MkdirAll(".git/objects/pack", 0755)
	os.MkdirAll(".git/objects/info", 0755)
	os.MkdirAll(".git/info", 0755)  // Should have exclude file in it
	os.MkdirAll(".git/hooks", 0755) // should have sample hooks in it.
	os.MkdirAll(".git/branches", 0755)
	os.MkdirAll(".git/refs/heads", 0755)
	os.MkdirAll(".git/refs/tags", 0755)

	ioutil.WriteFile(".git/HEAD", []byte("ref: refs/heads/master\n"), 0644)
	ioutil.WriteFile(".git/config", []byte("[core]\n\trepositoryformatversion = 0\n\tbare = false\n"), 0644)
	ioutil.WriteFile(".git/description", []byte("Unnamed repository; edit this file 'description' to name the repository.\n"), 0644)

}
开发者ID:driusan,项目名称:go-git,代码行数:32,代码来源:init.go


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