本文整理汇总了Python中git.Repo.submodule_update方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.submodule_update方法的具体用法?Python Repo.submodule_update怎么用?Python Repo.submodule_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.submodule_update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [as 别名]
def update(self):
"""Update the local cloudlet git repo on disk from any origin."""
print "Updating cloudlet: %s" % (self.path)
repo = Repo(self.path)
repo.remotes.origin.pull()
repo.submodule_update()
示例2: create_submodule
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [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)
示例3: update_submodules
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [as 别名]
def update_submodules(logger, repo, repo_path, Repo):
"""Update any git submodules used."""
logger.info("Gathering all submodules...")
# Collect any submodules in use
sms = repo.submodules
# Ensure that there are actually submodules in use
if len(sms) > 0:
# Iterate over each submodule found
for sm in sms:
# Define submodule actual path
sm_path = repo_path + "/" + sm.path
# Define submodule repo
sm_repo = Repo(sm_path)
# Check for any changed files
sm_changed_files = sm_repo.index.diff(None)
if sm_changed_files != []:
logger.info("Stashing changed files found in submodule: %s" % sm.name)
# Stash any changed files found in submodule
sm_repo.git.stash()
sm_stashed_files = True
else:
sm_stashed_files = False
# Collect any untracked files in submodule
sm_untracked_files = sm_repo.untracked_files
if sm_untracked_files != []:
logger.info("The following untracked files found in submodule: %s"
% sm_untracked_files)
# Update the submodule
logger.info("Updating submodule: %s" % sm.name)
sm_repo.submodule_update()
if sm_stashed_files:
logger.info("Popping stashed files found in submodule: %s" % sm.name)
# Pop any stashed files found in submodule
sm_repo.git.stash('pop')
else:
logger.info("No submodules found.")
示例4: Repo
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [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.")
示例5: FirmwareBuilder
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [as 别名]
class FirmwareBuilder(object):
def __init__(self, repo_url=None, repo_branch='master', update_submodules=True, workingdir='.', architecture=None, esp_root=None):
self.repo = None
self.repo_url = repo_url
self.repo_branch = repo_branch
self.update_submodules = update_submodules
self.workingdir = workingdir
self.architecture = architecture or 'avr'
self.esp_root = esp_root
self.stream = sys.stderr
self.repo_info = {}
self.build_result = {}
self.variable_patterns = [
# Preprocessor defines .ino, .pde, .cpp, .h, e.g.
# #define HE_USER "testdrive"
'#define\s+(?P<name>{name})\s+(?P<value>.+)',
# Makefile variables, e.g.
# BOARD_TAG = pro328
'^(?!#)(?P<name>{name})\s+:?=\s+(?P<value>.*)$',
]
def acquire_source(self):
cache_dir = os.path.join(user_cache_dir('kotori'), 'firmware-builder', 'sources')
if not os.path.isdir(cache_dir): os.makedirs(cache_dir)
target_path = os.path.join(cache_dir, os.path.basename(self.repo_url))
log.info('Build path is {target_path}'.format(target_path=target_path))
# 1. Get hold of repository
if os.path.isdir(target_path):
# Define repository object from existing path
# http://gitpython.readthedocs.io/en/stable/tutorial.html#meet-the-repo-type
self.repo = Repo(target_path)
# Fetch updates from remote
# http://gitpython.readthedocs.io/en/stable/tutorial.html#handling-remotes
origin = self.repo.remotes.origin
log.info('Fetching updates from repository {repository}'.format(repository=origin.url))
origin.fetch(progress=ProgressPrinter())
else:
# Clone repository from a remote
log.info('Cloning repository {repository}'.format(repository=self.repo_url))
self.repo = Repo.clone_from(self.repo_url, target_path, progress=ProgressPrinter())
# Default effective gitref to given reference label (either branch/tag name or commit sha)
gitref_effective = self.repo_branch
# Compute effective gitref by searching the origin branches for the given reference label
origin = self.repo.remotes.origin
origin_branch_ref = origin.name + '/' + self.repo_branch
for ref in origin.refs:
if ref.name == origin_branch_ref:
gitref_effective = ref.name
# 2. Switch to designated branch/gitref
# http://gitpython.readthedocs.io/en/stable/tutorial.html#switching-branches
# Point the HEAD symbolic reference to the designated gitref
self.repo.head.reference = gitref_effective
# Brutally reset the index and working tree to match the pointed-to commit
# Attention: Don't do this on a real repository you are working on, data may get lost!
self.repo.head.reset(index=True, working_tree=True)
# 3. Initialize submodules
# http://gitpython.readthedocs.io/en/stable/tutorial.html#advanced-repo-usage
# update all submodules, non-recursively to save time, this method is very powerful, go have a look
if self.update_submodules:
log.info('Updating git submodules')
self.repo.submodule_update(recursive=True, progress=ProgressPrinter())
else:
log.info('Skip updating git submodules')
# Return some information about repository
self.repo_info = {
'remote': origin.url,
'ref': gitref_effective,
'commit': self.repo.head.commit.hexsha[:8],
}
def patch_files(self, filepatterns, data):
filepatterns = to_list(filepatterns)
directory = os.path.join(self.repo.working_dir, self.workingdir)
# cd into appropriate directory
#.........这里部分代码省略.........
示例6: run
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [as 别名]
def run(self, *args, **kwargs):
self.validate_config()
try:
local_directory = args[0]
except IndexError:
local_directory = config['source']['local']
try:
repo_directory = args[1]
except IndexError:
repo_directory = config['source']['git']['local']
branch = config['source']['git']['branch']
repo = config['source']['git']['repo']
env.host_string = 'localhost'
pretty_print('[+] Repository clone start: %s' % local_directory, 'info')
# if not len(directory):
# pretty_print('Directory not selected, assuming current one.', 'info')
# directory = os.getcwd()
# if os.path.isdir(directory):
# pretty_print('Directory found.', 'info')
# else:
# try:
# pretty_print('Directory not found, creating.', 'info')
# os.mkdir(directory)
# except:
# raise Exception('Cannot create directory %s, please create the folder manually' % directory)
old_dir = os.getcwd()
os.chdir(local_directory)
try:
if not os.path.isdir("%s/.git" % repo_directory): # repo = Repo(dir)
if os.path.isdir(repo_directory):
raise IOError('Directory already exists and is not repository. Clone will fail. Please check your '
'configuration')
raise InvalidGitRepositoryError()
repo = Repo(repo_directory)
pretty_print('Repository found. Branch: %s' % repo.active_branch, 'info')
except InvalidGitRepositoryError: # Repo doesn't exists
pretty_print('Repository not found. Creating new one, using %s.' % repo, 'info')
if len(repo) == 0:
pretty_print('Repository not selected. Returning.', 'info')
raise InvalidGitRepositoryError
repo = Repo.clone_from(repo, repo_directory)
if not len(branch):
branch = repo.active_branch
if repo.active_branch is not branch:
pretty_print('Changing branch', 'info')
repo.git.checkout('master')
pretty_print('Pulling changes', 'info')
repo.git.pull('origin', branch)
pretty_print('Fetching submodules', 'info')
repo.git.submodule("init")
repo.submodule_update(init=True)
os.chdir(old_dir)
#repo.create_remote('origin', config.GIT_REPO)
pretty_print('[+] Repository clone finished', 'info')
示例7: call
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import submodule_update [as 别名]
PIP_LIBS = ['GitPython==0.3.2.RC1', 'bottle', 'rauth', 'requests', 'pymongo', 'gevent', 'gevent-websocket', 'greenlet',
'numpy', 'jdcal','pycrypto']
from subprocess import call # for sys commands
try:
call([PIP, 'install'] + PIP_LIBS)
except OSError:
print ("\n\nCan't find pip at "+PIP+
"\nIs python-pip installed? If the error was about vcvarsall.bat, "
"see the solution here: http://stackoverflow.com/a/10558328/1483986\n\n")
raise
# install/update submodules using GitPython
from os import getcwd, path
from git import Repo
repo = Repo(getcwd())
assert repo.bare == False
print "Installing submodules..."
repo.submodule_update() # inits and updates all submodules listed in .gitmodules
# create __init__.py in each submodule root directory if there isn't one (fixes bottle import issue)
for module in repo.submodules:
init_path = path.join(module.abspath, '__init__.py')
if not path.isfile(init_path):
open(init_path, 'a').close()
print '\n\nDone! Hopefully all went well and you can run `python app.py` now!'