本文整理汇总了Python中dulwich.config.StackedConfig.default方法的典型用法代码示例。如果您正苦于以下问题:Python StackedConfig.default方法的具体用法?Python StackedConfig.default怎么用?Python StackedConfig.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dulwich.config.StackedConfig
的用法示例。
在下文中一共展示了StackedConfig.default方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ls_remote
# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default [as 别名]
def ls_remote(remote, config=None, **kwargs):
"""List the refs in a remote.
:param remote: Remote repository location
:param config: Configuration to use
:return: Dictionary with remote refs
"""
if config is None:
config = StackedConfig.default()
client, host_path = get_transport_and_path(remote, config=config, **kwargs)
return client.get_refs(host_path)
示例2: clone
# 需要导入模块: from dulwich.config import StackedConfig [as 别名]
# 或者: from dulwich.config.StackedConfig import default [as 别名]
def clone(source, target=None, bare=False, checkout=None,
errstream=default_bytes_err_stream, outstream=None,
origin=b"origin", **kwargs):
"""Clone a local or remote git repository.
:param source: Path or URL for source repository
:param target: Path to target repository (optional)
:param bare: Whether or not to create a bare repository
:param checkout: Whether or not to check-out HEAD after cloning
:param errstream: Optional stream to write progress to
:param outstream: Optional stream to write progress to (deprecated)
:param origin: Name of remote from the repository used to clone
:return: The new repository
"""
# TODO(jelmer): This code overlaps quite a bit with Repo.clone
if outstream is not None:
import warnings
warnings.warn(
"outstream= has been deprecated in favour of errstream=.",
DeprecationWarning, stacklevel=3)
errstream = outstream
if checkout is None:
checkout = (not bare)
if checkout and bare:
raise ValueError("checkout and bare are incompatible")
config = StackedConfig.default()
client, host_path = get_transport_and_path(source, config=config, **kwargs)
if target is None:
target = host_path.split("/")[-1]
if not os.path.exists(target):
os.mkdir(target)
if bare:
r = Repo.init_bare(target)
else:
r = Repo.init(target)
reflog_message = b'clone: from ' + source.encode('utf-8')
try:
fetch_result = fetch(r, host_path, origin, message=reflog_message)
target_config = r.get_config()
if not isinstance(source, bytes):
source = source.encode(DEFAULT_ENCODING)
target_config.set((b'remote', origin), b'url', source)
target_config.set(
(b'remote', origin), b'fetch',
b'+refs/heads/*:refs/remotes/' + origin + b'/*')
target_config.write_to_path()
# TODO(jelmer): Support symref capability,
# https://github.com/jelmer/dulwich/issues/485
try:
head = r[fetch_result[b'HEAD']]
except KeyError:
head = None
else:
r[b'HEAD'] = head.id
if checkout and not bare and head is not None:
errstream.write(b'Checking out ' + head.id + b'\n')
r.reset_index(head.tree)
except BaseException:
r.close()
raise
return r