本文整理汇总了Python中git.repo.Repo.init方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.init方法的具体用法?Python Repo.init怎么用?Python Repo.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.repo.Repo
的用法示例。
在下文中一共展示了Repo.init方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _prepare
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
def _prepare(cls, create, **kwargs):
tuto = super(MiniTutorialFactory, cls)._prepare(create, **kwargs)
path = tuto.get_path()
if not os.path.isdir(path):
os.makedirs(path, mode=0o777)
man = export_tutorial(tuto)
repo = Repo.init(path, bare=False)
repo = Repo(path)
file = open(os.path.join(path, 'manifest.json'), "w")
file.write(
json_writer.dumps(
man,
indent=4,
ensure_ascii=False).encode('utf-8'))
file.close()
file = open(os.path.join(path, tuto.introduction), "w")
file.write(contenu.encode('utf-8'))
file.close()
file = open(os.path.join(path, tuto.conclusion), "w")
file.write(contenu.encode('utf-8'))
file.close()
repo.index.add(['manifest.json', tuto.introduction, tuto.conclusion])
cm = repo.index.commit("Init Tuto")
tuto.sha_draft = cm.hexsha
return tuto
示例2: _prepare
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
def _prepare(cls, create, **kwargs):
article = super(ArticleFactory, cls)._prepare(create, **kwargs)
path = article.get_path()
if not os.path.isdir(path):
os.makedirs(path, mode=0o777)
man = export_article(article)
repo = Repo.init(path, bare=False)
repo = Repo(path)
f = open(os.path.join(path, 'manifest.json'), "w")
f.write(json_writer.dumps(man, indent=4, ensure_ascii=False).encode('utf-8'))
f.close()
f = open(os.path.join(path, article.text), "w")
f.write(u'Test')
f.close()
repo.index.add(['manifest.json', article.text])
cm = repo.index.commit("Init Article")
article.sha_draft = cm.hexsha
return article
示例3: setup
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
def setup(self):
git_opts = self._config
if git_opts['url'] is None:
raise Exception('Remote git URL not set.')
self._url = git_opts['url']
default_clone_dir = os.path.join(os.path.dirname(__file__), 'clones')
self._local_path = git_opts.get('local_clone_path', default_clone_dir)
self._poll_interval = git_opts.get('poll_interval', self._poll_interval)
if os.path.exists(self._local_path):
self._repo = Repo.init(self._local_path)
else:
try:
self._repo = Repo.clone_from(self._url, self._local_path)
except Exception:
self._logger.exception('Unable to clone remote repo from %s',
self._url)
raise
self._remote = self._repo.remote('origin')
示例4: prepare_historage_repo
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
def prepare_historage_repo(self):
historage_repo = Repo.init(self.historage_dir, bare=self.is_bare_repo)
self.set_git_config(historage_repo)
return historage_repo
示例5: prepare_base_repo
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
def prepare_base_repo(self):
base_repo = Repo.init(self.historage_dir, bare=self.is_bare_repo)
return base_repo
示例6: mktree_from_iter
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
tree_contents = []
tree_contents.append((conf_mode, conf_binsha, ".gitmodules"))
tree_contents.append(get_submodule_tree_content(submodule_commit_hexsha, "jEdit"))
tree_mode, binsha = mktree_from_iter(odb, tree_contents)
return bin_to_hex(binsha)
if __name__ == "__main__":
from kenja.git.util import get_reversed_topological_ordered_commits
repo = Repo("/Users/kenjif/msr_repos/git/jEdit")
commits = get_reversed_topological_ordered_commits(repo, repo.refs)
new_repo = Repo.init("/Users/kenjif/test_git_repo")
with open("/Users/kenjif/test_gitmodules", "wb") as f:
name = "jEdit"
path = "jEdit"
url = "/Users/kenjif/msr_repos/git/jEdit"
write_submodule_config(f, name, path, url)
committed = {}
tags = {}
heads = {}
for tag_ref in repo.tags:
tags[tag_ref.commit.hexsha] = tag_ref.name
for head in repo.heads:
heads[head.commit.hexsha] = head.name
示例7:
# 需要导入模块: from git.repo import Repo [as 别名]
# 或者: from git.repo.Repo import init [as 别名]
children = []
for parent in commit.parents:
if parent.hexsha not in visited:
children.append(parent.hexsha)
if children:
nodes.extend(children)
else:
nodes.pop()
visited.add(node)
post.append(node)
return post
if __name__ == '__main__':
repo = Repo.init('test_git')
# (mode, binsha) = write_tree(repo.odb, 'temp')
# (mode, binsha) = write_tree(repo.odb, 'temp/00')
# (mode, binsha) = write_tree(repo.odb, 'temp/01')
paths = ['temp/00', 'temp/01']
names = ['a', 'b']
(mode, binsha) = write_paths(repo.odb, paths, names)
tree = Tree.new(repo, bin_to_hex(binsha))
c = Commit.create_from_tree(repo, tree, 'test commit', None, True)