当前位置: 首页>>代码示例>>Python>>正文


Python Shell.git方法代码示例

本文整理汇总了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
开发者ID:rajpushkar83,项目名称:base,代码行数:34,代码来源:gitinfo.py

示例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]}
开发者ID:rajpushkar83,项目名称:base,代码行数:29,代码来源:gitinfo.py

示例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")
开发者ID:rajpushkar83,项目名称:base,代码行数:22,代码来源:version_incr.py

示例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
开发者ID:rajpushkar83,项目名称:base,代码行数:19,代码来源:gitinfo.py

示例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
开发者ID:rajpushkar83,项目名称:base,代码行数:26,代码来源:gitinfo.py

示例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]
开发者ID:rajpushkar83,项目名称:base,代码行数:4,代码来源:setup.py

示例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]
开发者ID:rajpushkar83,项目名称:base,代码行数:8,代码来源:gitinfo.py

示例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())
开发者ID:rajpushkar83,项目名称:base,代码行数:32,代码来源:gitinfo.py

示例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)
开发者ID:rajpushkar83,项目名称:base,代码行数:6,代码来源:version_incr.py


注:本文中的cloudmesh_base.Shell.Shell.git方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。