本文整理汇总了Python中git.Repo.delete_remote方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.delete_remote方法的具体用法?Python Repo.delete_remote怎么用?Python Repo.delete_remote使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Repo
的用法示例。
在下文中一共展示了Repo.delete_remote方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feedstocks_clone_all_handle_args
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_remote [as 别名]
def feedstocks_clone_all_handle_args(args):
for repo in feedstock_repos(args.organization):
clone_directory = os.path.join(args.feedstocks_directory, repo.name)
if not os.path.exists(clone_directory):
print('Cloning {}'.format(repo.name))
new_repo = Repo.clone_from(repo.ssh_url, clone_directory)
clone = Repo(clone_directory)
if 'upstream' in [remote.name for remote in clone.remotes]:
clone.delete_remote('upstream')
clone.create_remote('upstream', url=repo.ssh_url)
示例2: clone_feedstock
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_remote [as 别名]
def clone_feedstock(feedstock_gh_repo, feedstocks_dir):
repo = feedstock_gh_repo
clone_directory = os.path.join(feedstocks_dir, repo.name)
if not os.path.exists(clone_directory):
print('Cloning {}'.format(repo.name))
new_repo = Repo.clone_from(repo.ssh_url, clone_directory)
clone = Repo(clone_directory)
if 'upstream' in [remote.name for remote in clone.remotes]:
clone.delete_remote('upstream')
clone.create_remote('upstream', url=repo.ssh_url)
示例3: run
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_remote [as 别名]
def run(self):
os.seteuid(0)
os.setgid(self.gid)
os.setuid(self.uid)
# In case of nonexistent path or empty directory clone the repository.
# Otherwise open it.
try:
if not os.path.exists(self.local) or not os.listdir(self.local):
os.umask(0022)
logger.info("Cloning repo '%s' from '%s' to '%s'" % (self.name, self.remote, self.local))
repo = Repo.clone_from(self.remote, self.local)
else:
logger.info("Loading repo '%s' at '%s'" % (self.name, self.local))
repo = Repo(self.local)
# To make sure our remote is up to date, we delete and create it
# again.
if 'watchgit' in [remote.name for remote in repo.remotes]:
logger.debug("Deleting remote 'watchgit' from repository '%s'" % self.name)
repo.delete_remote('watchgit')
logger.debug("Creating remote '%s' on repository '%s'" % (self.remote, self.name))
remotes = [repo.create_remote('watchgit', self.remote)]
# if all_remotes is set we pull from all remotes
if self.all_remotes is True:
remotes = repo.remotes
# If skip_on_error is true, we don't need to raise a fatal exception.
# Instead we signal our watcher with the exitcode that we failed while
# trying to load the repo.
except Exception as e:
if self.skip_on_error is True:
logger.warn(e, exc_info=1)
os._exit(128)
else:
raise
# Start the watch
logger.info("Starting watch of repository at '%s'" % repo.working_dir)
while True:
logger.debug("Pulling ref '%s' for '%s'" % (self.ref, repo.working_dir))
if self.reset is True and repo.is_dirty():
logger.info("Resetting dirty repository at '%s'" % repo.working_dir)
repo.head.reset(working_tree=True)
for remote in remotes:
logger.debug("Pulling remote '%s'", remote.name)
remote.pull(self.ref)
time.sleep(self.interval)
示例4: clone
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_remote [as 别名]
def clone(self):
if not os.path.exists(self.build_dir):
print(green('Cloning %s into %s' % (self.origin, self.build_dir)))
repo = Repo.init(self.build_dir)
repo.create_remote('origin', self.origin)
else:
print(green('Fetch updates for %s' % self.build_dir))
repo = Repo(self.build_dir)
if repo.remotes.origin.url != self.origin: # update remote if desired
repo.delete_remote(repo.remotes.origin)
repo.create_remote('origin', self.origin)
repo.git.checkout('master', f=True)
repo.remotes.origin.fetch(tags=True)
repo.remotes.origin.pull('master')
return repo
示例5: check_git_repos
# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import delete_remote [as 别名]
def check_git_repos(cmdargs):
# path gived by user
root = cmdargs.path
# Bitbucket crendentials
pwd = BITBUCKET_PASSWORD
user = BITBUCKET_USER
owner = cmdargs.owner
if(os.path.exists(cmdargs.path)):
formated_root = os.path.abspath(root)
#get the repos dirs
repo_dirs = get_repos_dirs(formated_root)
for repo_dir in repo_dirs:
# get the repo name from remote origin url as <name>.git
g = cmd.Git(repo_dir)
# if repo has origin set name based on it
try:
repo_name = g.execute(["git", "config", "--get", "remote.origin.url"]).split('/')[-1].split(".")[0]
except:
# if repo has not origin set name based on its folder name
repo_name = repo_dir.split('/')[-1].lower().replace(" ","_")
repo_name = slugify(repo_name)
# @TODO: Maybe picorb could be replaced with a sysargv
url = '[email protected]:%s/%s'%(owner,repo_name)
repo = Repo(repo_dir)
# create a temporal remote
try:
# delete bitbucket_remote if it exists
repo.delete_remote('bitbucket_remote')
except:
pass
bitbucket_remote = repo.create_remote('bitbucket_remote',url)
# create the bitbucket repo
create_bitbucket_repo(user, pwd, owner, repo_name)
print repo_name
# check if repo has uncommited changes
if (repo.is_dirty() or len(repo.untracked_files)>0):
print "This repo is dirty: ", repo_name
# create/change branch
try:
g.execute(["git", "checkout", "-b", "uncommited"])
except:
g.execute(["git", "checkout", "uncommited"])
g.execute(["git", "add", "-A"])
g.execute(["git", "commit", "-m", '"uncommited changes"'])
# Push all branches to the new remote
g.execute(["git", "push", "bitbucket_remote", "--all"])
# delete temporal remote
repo.delete_remote(bitbucket_remote)
else:
sys.stderr.write('Please enter a valid path. \n')