本文整理汇总了Python中git.Repo.create_submodule方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.create_submodule方法的具体用法?Python Repo.create_submodule怎么用?Python Repo.create_submodule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.create_submodule方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_submodule
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_submodule [as 别名]
def create_submodule():
repo = Repo(blog_path)
if not any(normpath(x.abspath) == normpath(full_path(pelicanconf.OUTPUT_PATH)) for x in repo.submodules):
logging.warn("Output submodule {0} doesn't exists, creating it at {1}.".format(
publishconf.SUBMODULE_NAME, publishconf.OUTPUT_PATH))
repo.create_submodule(url=publishconf.GITHUB_REPO, name=publishconf.SUBMODULE_NAME,
path=publishconf.OUTPUT_PATH, branch="master")
repo.submodule_update(init=True)
示例2: Repo
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_submodule [as 别名]
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('feedstocks_repo', help="The location of the checked out conda-forge/feedstocks repo.")
args = parser.parse_args()
feedstocks_repo = Repo(args.feedstocks_repo)
for feedstock in feedstocks.feedstock_repos('conda-forge'):
repo_subdir = os.path.join('feedstocks', feedstock.package_name)
abs_subdir = os.path.join(feedstocks_repo.working_tree_dir, repo_subdir)
sm_names = [sm.name for sm in feedstocks_repo.submodules]
if not os.path.exists(abs_subdir):
print('Adding {} to submodules.'.format(feedstock.package_name))
# For situations where the submodule already exists, but not in the expected locations, just
# remove it, and re-add.
if feedstock.package_name in sm_names:
feedstocks_repo.submodules[feedstock.package_name].remove()
# Add the new submodule.
feedstocks_repo.create_submodule(feedstock.package_name, repo_subdir,
url=feedstock.clone_url,
branch='master')
feedstocks_repo.submodule_update(recursive=False)
if feedstocks_repo.is_dirty():
feedstocks_repo.index.add(['.gitmodules'])
feedstocks_repo.index.commit("Updated feedstocks submodules.")
示例3: remove_file
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_submodule [as 别名]
remove_file('{{ cookiecutter.module_name }}/example_mod.py')
remove_file('{{ cookiecutter.module_name }}/tests/test_example.py')
if '{{ cookiecutter.include_example_cython_code }}' != 'y':
remove_file('{{ cookiecutter.module_name }}/example_c.pyx')
if '{{ cookiecutter.initialize_git_repo }}' == 'y':
try:
from git import Repo
new_repo = Repo.init(PROJECT_DIRECTORY)
new_repo.git.add('.')
new_repo.index.commit(
"Creation of {{ cookiecutter.package_name }} from astropy package template"
)
if '{{ cookiecutter.astropy_helpers_version }}':
Repo.create_submodule(
new_repo, "astropy_helpers", "astropy_helpers",
"https://github.com/astropy/astropy-helpers.git",
"{{ cookiecutter.astropy_helpers_version }}")
new_repo.submodules[0].update()
new_repo.index.commit(
"Initialize astropy_helpers at version {{ cookiecutter.astropy_helpers_version }}"
)
except ImportError:
print(
"gitpython is not installed so the repository will not be initialised "
"and astropy_helpers not downloaded.")
示例4: print
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import create_submodule [as 别名]
# Identify the submodule names which lie withing the repo.
submodules = {sm.name: sm for sm in feedstocks_repo.submodules}
for feedstock in forge_feedstocks:
repo_subdir = os.path.join('feedstocks', feedstock.package_name)
abs_subdir = os.path.join(feedstocks_repo.working_tree_dir, repo_subdir)
if not os.path.exists(abs_subdir):
print('Adding {} to submodules.'.format(feedstock.package_name))
# For situations where the submodule already exists, but not in the expected locations, just
# remove it, and re-add.
if feedstock.package_name in submodules:
feedstocks_repo.submodules[feedstock.package_name].remove()
# Add the new submodule.
feedstocks_repo.create_submodule(feedstock.package_name, repo_subdir,
url=feedstock.clone_url)
# Pick out the feedstocks which exist on the repo, but are no longer on conda-forge.
to_be_deleted = set(submodules.keys()) - set(repo.package_name for repo in forge_feedstocks)
for package_name in to_be_deleted:
print("Removing {}.".format(package_name))
submodule = submodules[package_name].remove()
feedstocks_repo.submodule_update(recursive=False)
feedstocks_repo.git.submodule('foreach', 'git', 'pull', 'origin', 'master')
if feedstocks_repo.is_dirty():
feedstocks_repo.git.commit('-a', '-m', 'Updated feedstocks submodules.')