本文整理汇总了Python中git.Git.add方法的典型用法代码示例。如果您正苦于以下问题:Python Git.add方法的具体用法?Python Git.add怎么用?Python Git.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Git
的用法示例。
在下文中一共展示了Git.add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addSuperModuleCommit
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import add [as 别名]
def addSuperModuleCommit(self, id, hash, url, who, branch, project):
self.log.debug("branch: " + branch + ", project:" + project)
hasSuperModule = False
isSuperModuleBr = False
self.log.debug("Project names: " + str(self.config.projects))
projectNames = self.config.projects.keys()
for proj in projectNames:
self.log.debug("project: " + project + " proj: " + proj)
if project.lower() == proj:
hasSuperModule = True
break
for br in self.config.branches:
if branch == br:
isSuperModuleBr = True
break
self.log.debug("isSuperModuleBr: " + str(isSuperModuleBr) + " hasSuperModule: " + str(hasSuperModule))
if isSuperModuleBr and hasSuperModule:
self.log.debug("Git Profile Path: " + str(self.config.profile))
git = Git(self.config.profile)
self.checkoutTrackingBranch(git, branch)
git.pull()
git.submodule("update","--init")
gitSubmoduleProfile = {'git':self.config.superRepoPath + self.config.projects[project.lower()]}
gitSubmodule = Git(gitSubmoduleProfile)
self.log.debug("checking out hash: " + hash)
gitSubmodule.fetch()
if self.isOptOut(gitSubmodule, hash):
return
gitSubmodule.checkout(hash, True)
git.add(".")
commitMsg = "Auto checkin: " + self.getCommitMessage(gitSubmodule, hash) + "\nuser:" + who + "\nhash:" + hash + "\nproject: " + project
self.log.debug("commiting in super module: " + commitMsg)
git.commit(commitMsg)
self.log.debug("pushing super module to branch: " + branch)
git.push(branch)
else:
self.log.debug("No super module commit is required.")
示例2: created_quark
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import add [as 别名]
def created_quark(self, sender, new_quark):
options = sender.options
if self.git_is_installed():
g = Git(options['path'])
g.init()
default_ignore = os.path.join(os.path.dirname(__file__), '..', 'default_gitignore.txt')
ignore_path = os.path.join(options['path'], '.gitignore')
with open(ignore_path, 'w') as ignore_file, open(default_ignore, 'r') as default_file:
ignore_file.write(default_file.read())
user_ignores = settings.user_gitignore()
if user_ignores:
ignore_file.write('\n#SUPPLIED FROM ~/.qpmignore\n\n')
ignore_file.write(user_ignores)
g.add(new_quark.get_quarkfile_path(options['path']))
g.commit(m='Created quarkfile.')
g.add('.gitignore')
g.commit(m='Created gitignore.')
g.add('.')
if Repo(options['path']).is_dirty():
g.commit(m='Initial commit of existing files.')
g.tag(options['version'])
else:
self.msg(
'WARNING: Git is not installed. Try http://git-scm.com/ or run the following:\n'
+ '\truby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"; brew install git'
)
示例3: Git
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import add [as 别名]
if not os.path.isdir(dirpath):
os.mkdir(dirpath)
g = Git(dirpath)
# If is not Git repository, git init
if not git.repo.fun.is_git_dir(dirpath):
# bare repository
if args.__dict__.get('b'):
repo = g.init(dirpath, bare=True)
else:
# local repository
g.init()
# Make .gitignore
if not os.path.isfile(dirpath + '/.gitignore'):
f = open(dirpath + '/.gitignore', 'w')
f.write('')
f.close()
# git add .gitignore and first commit
if g.untracked_files or g.is_dirty():
# git add
g.add('.gitignore')
# git commit
g.commit(m='First commit')
except RuntimeError as e:
sys.stderr.write("ERROR: %s\n" % e)