本文整理汇总了Python中git.Git.module_name方法的典型用法代码示例。如果您正苦于以下问题:Python Git.module_name方法的具体用法?Python Git.module_name怎么用?Python Git.module_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类git.Git
的用法示例。
在下文中一共展示了Git.module_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Attach
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import module_name [as 别名]
class Attach():
def __init__(self):
self.git = Git()
self.parser = OptionParser()
self.parser.set_usage("mgit attach <subproject name>")
def print_usage(self):
self.parser.print_usage()
def run(self, args):
options, args = self.parser.parse_args(args[1:])
if len(args) <= 0:
self.parser.print_usage()
return
if len(args) > 1:
module = args[1]
else:
module = self.git.module_name(args[0])
if module == None or len(module) <= 0:
return
if not os.path.exists(module):
print("module %s not exists." % module)
return
project = Project()
project.append(module)
示例2: Clone
# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import module_name [as 别名]
class Clone():
def __init__(self):
self.git = Git()
self.parser = OptionParser()
self.parser.add_option("-b", "--branch", dest="branch", help="with checkout branch")
self.parser.add_option("-C", "--repo-dir", dest="repodir", help="repo directory")
self.parser.add_option("-R", "--recursive", dest="recursive", help="clone project and subproject recursively")
self.parser.set_usage("mgit clone <url> [-b <branch>]")
def print_usage(self):
self.parser.print_usage()
def run(self, orig_args):
options,args = self.parser.parse_args(orig_args)
args = args[1:]
if len(args) <= 0:
self.print_usage()
return
project_dir = self.git.module_name(args[0])
if project_dir == None or len(project_dir) <= 0:
print("Unknow project name.Please use git clone, then use mgit sync in the project dir.")
return
cmd = ['git', 'clone'] + args
if options.branch != None:
cmd += ["-b", options.branch]
if 0 != os.system(" ".join(cmd)):
return
cwd = os.getcwd()
os.chdir("/".join([cwd, project_dir]))
sync = Sync()
sync.run(['sync'] + orig_args[1:])
os.chdir(cwd)