本文整理汇总了Python中cloudmesh_base.Shell.Shell.git方法的典型用法代码示例。如果您正苦于以下问题:Python Shell.git方法的具体用法?Python Shell.git怎么用?Python Shell.git使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cloudmesh_base.Shell.Shell
的用法示例。
在下文中一共展示了Shell.git方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_authors_by_date
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def get_authors_by_date(header=False):
"""lists the authors of a git repository sorted by date.
Example:
0001 (2015-02-25): Gregor von Laszewski ([email protected])
0002 (2015-04-14): Fugang Wang ([email protected])
:rtype: str
"""
# modified from https://github.com/jgehrcke/git-authors
result = ""
# if header:
# result = result + "Authors\n"
# result = result + "=======\n\n"
r = Shell.git("log",
"--encoding=utf-8",
"--full-history",
"--reverse",
"--format=format:%at;%an;%ae").split("\n")
seen = set()
for line in r:
timestamp, name, email = line.strip().split(";")
if name not in seen:
seen.add(name)
day = time.strftime("%Y-%m-%d", time.gmtime(float(timestamp)))
result = result + "* {:04d} ({:}): {:} ({:})\n".format(len(seen), day, name, email)
return result
示例2: stat
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def stat(self, email):
"""
returns a statistic of a git author with the given e_mail.
:param email: name of the author
:rtype: a dict with the statistics
"""
result = Shell.git("log", "--all", "--stat", '--author={0}'.format(email)).split("\n")
sums = [0, 0, 0]
for line in result:
if " files changed" in line:
line = line.strip()
line = line.replace(" insertions(+)", "")
line = line.replace(" insertion(+)", "")
line = line.replace(" deletion(-)", "")
line = line.replace(" deletions(-)", "")
line = line.replace(" files changed", "")
line = line.split(",")
data = [int(i) for i in line]
for index in range(0, len(data)):
sums[index] += data[index]
return {"email": email,
"fileschanged": sums[0],
"inserted": sums[1],
"deleted": sums[2],
"lineschanged": sums[1] + sums[2]}
示例3: tag
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def tag(self):
v = self.find()
banner("v")
print v
#v = ".".join(self.version)
os.system("python shell_plugins.py install")
if self.git_commit_needed():
banner("git commit")
command = "git commit -m 'version {:}' {:}".format(v,self.filename)
print "CCC", command
os.system(command)
os.system("git push")
else:
print "git commit not needed"
Shell.git("tag", "-a", v, "-m", "version {:}".format(v))
Shell.git("push", "origin", "--tags")
示例4: authors
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def authors(self, output=None):
"""
returns the authors of the authors either as a text or as a dict. The
format is specified as an argument.
:param output: if "dict" is specified a dict will be returned
"""
result = Shell.git("shortlog", "-s", "-n")
if output is None:
return result
elif output == "dict":
authors = {}
for line in result.split("\n"):
l = " ".join(line.split()).strip()
(number, name) = l.split(" ", 1)
authors[name] = int(number)
return authors
示例5: emails
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def emails(self, output=None):
"""
returns the emails of the authors either as a text or as a dict. The
format is specified as an argument.
:param output: if "dict" is specified a dict will be returned
:rtype: dict or array of e-mails dependent on output
"""
format_string = "'%aN' <%cE>"
if output == 'dict':
format_string = "%aN\t%cE"
result = sorted(set(Shell.git("log",
"--all",
"--format=" + format_string).split("\n")))
if output is None:
return result
elif output == "dict":
emails = {}
for l in result:
(name, email) = l.split("\t")
emails[name] = email
return emails
示例6: get_version_from_git
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def get_version_from_git():
return Shell.git('tag').split("\n")[-1]
示例7: version
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def version(self):
"""
returns the verison of the code from github
:rtype: the git tags
"""
return str(Shell.git("describe", "--tags"))[:-1]
示例8: float
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
sums["deleted"] += stats[email]["deleted"]
sums["lineschanged"] += stats[email]["lineschanged"]
for email in emails:
stats[email] = {'percentage': [
stats[email]["fileschanged"] / float(sums["fileschanged"]),
stats[email]["inserted"] / float(sums["inserted"]),
stats[email]["deleted"] / float(sums["deleted"]),
stats[email]["lineschanged"] / float(sums["lineschanged"])
]}
return stats
if __name__ == "__main__":
print (Shell.git("shortlog", "-n", "-s"))
gitinfo = GitInfo()
# print gitinfo.version()
banner("a")
print(gitinfo.authors())
banner("b")
pprint(gitinfo.authors("dict"))
banner("c")
pprint(gitinfo.emails())
示例9: git_commit_needed
# 需要导入模块: from cloudmesh_base.Shell import Shell [as 别名]
# 或者: from cloudmesh_base.Shell.Shell import git [as 别名]
def git_commit_needed(self):
content = Shell.git("status")
return ("Changes to be committed:" in content) or \
('Your branch is ahead' in content)