本文整理汇总了Python中git.Git.polish_url方法的典型用法代码示例。如果您正苦于以下问题:Python Git.polish_url方法的具体用法?Python Git.polish_url怎么用?Python Git.polish_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Git
的用法示例。
在下文中一共展示了Git.polish_url方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remote_repo_creator
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import polish_url [as 别名]
def remote_repo_creator(self):
rw_daemon_repo_dir = tempfile.mktemp(prefix="daemon_repo-%s-" % func.__name__)
rw_repo_dir = tempfile.mktemp(prefix="daemon_cloned_repo-%s-" % func.__name__)
rw_daemon_repo = self.rorepo.clone(rw_daemon_repo_dir, shared=True, bare=True)
# recursive alternates info ?
rw_repo = rw_daemon_repo.clone(rw_repo_dir, shared=True, bare=False, n=True)
try:
rw_repo.head.commit = working_tree_ref
rw_repo.head.reference.checkout()
# prepare for git-daemon
rw_daemon_repo.daemon_export = True
# this thing is just annoying !
with rw_daemon_repo.config_writer() as crw:
section = "daemon"
try:
crw.add_section(section)
except Exception:
pass
crw.set(section, "receivepack", True)
# Initialize the remote - first do it as local remote and pull, then
# we change the url to point to the daemon.
d_remote = Remote.create(rw_repo, "daemon_origin", rw_daemon_repo_dir)
d_remote.fetch()
base_daemon_path, rel_repo_dir = osp.split(rw_daemon_repo_dir)
remote_repo_url = Git.polish_url("git://localhost:%s/%s" % (GIT_DAEMON_PORT, rel_repo_dir))
with d_remote.config_writer as cw:
cw.set('url', remote_repo_url)
with git_daemon_launched(Git.polish_url(base_daemon_path, is_cygwin=False), # No daemon in Cygwin.
'127.0.0.1',
GIT_DAEMON_PORT):
# Try listing remotes, to diagnose whether the daemon is up.
rw_repo.git.ls_remote(d_remote)
with cwd(rw_repo.working_dir):
try:
return func(self, rw_repo, rw_daemon_repo)
except:
log.info("Keeping repos after failure: \n rw_repo_dir: %s \n rw_daemon_repo_dir: %s",
rw_repo_dir, rw_daemon_repo_dir)
rw_repo_dir = rw_daemon_repo_dir = None
raise
finally:
rw_repo.git.clear_cache()
rw_daemon_repo.git.clear_cache()
del rw_repo
del rw_daemon_repo
import gc
gc.collect()
if rw_repo_dir:
rmtree(rw_repo_dir)
if rw_daemon_repo_dir:
rmtree(rw_daemon_repo_dir)
示例2: test_is_dirty_with_path
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import polish_url [as 别名]
def test_is_dirty_with_path(self, rwrepo):
assert rwrepo.is_dirty(path="git") is False
with open(osp.join(rwrepo.working_dir, "git", "util.py"), "at") as f:
f.write("junk")
assert rwrepo.is_dirty(path="git") is True
assert rwrepo.is_dirty(path="doc") is False
rwrepo.git.add(Git.polish_url(osp.join("git", "util.py")))
assert rwrepo.is_dirty(index=False, path="git") is False
assert rwrepo.is_dirty(path="git") is True
with open(osp.join(rwrepo.working_dir, "doc", "no-such-file.txt"), "wt") as f:
f.write("junk")
assert rwrepo.is_dirty(path="doc") is False
assert rwrepo.is_dirty(untracked_files=True, path="doc") is True
示例3: _small_repo_url
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import polish_url [as 别名]
def _small_repo_url(self):
""":return" a path to a small, clonable repository"""
from git.cmd import Git
return Git.polish_url(osp.join(self.rorepo.working_tree_dir, 'git/ext/gitdb/gitdb/ext/smmap'))