Beispiel #1
0
    def emails(self, format_arg=None):
        '''
        returns the emails of the authors either as a text or as a dict. The
        format is specified as an argument.

        :param format_arg: if "dict" is specified a dict will be returned
        :rtype: dict or arry of e-mails dependent on format_arg
        '''
        if format_arg is None:
            format_string = "'%aN' <%cE>"
        elif format_arg == 'dict':
            format_string = "%aN\t%cE"
        result = Shell.sort(Shell.git("log",
                                      "--all",
                                      "--format=" + format_string,
                                      _tty_in=True,
                                      _tty_out=False,
                                      _piped=True), "-u")

        if format_arg is None:
            return result
        elif format_arg == "dict":
            result = iter(result.replace("\n", "\t").split("\t")[:-1])
            emails = dict(zip(result, result))
            for name in emails:
                emails[name] = emails[name]
            return emails
Beispiel #2
0
    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
        '''
        sums = [0, 0, 0]
        for line in Shell.git("log", "--all", "--stat", '--author={0}'.format(email),
                              _tty_in=True,
                              _tty_out=False,
                              _iter=True):
            line = line[:-1]

            if " files changed" in line:
                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]}
Beispiel #3
0
    def authors(self, format_arg=None):
        '''
        returns the authors of the authors either as a text or as a dict. The
        format is specified as an argument.

        :param format_arg: if "dict" is specified a dict will be returned
        '''
        result = Shell.git("shortlog", "-s", "-n", _tty_in=True, _tty_out=False)
        if format_arg is None:
            return result
        elif format_arg == "dict":
            list_string = result.replace("\n", "\t").split("\t")[:-1]
            it = iter(list_string[::-1])
            authors = dict(zip(it, it))
            for name in authors:
                authors[name] = int(authors[name])
            return authors
Beispiel #4
0
 def version(self):
     '''
     retruns the verison of the code from github
     :rtype: the git tags
     '''
     return str(Shell.git("describe", "--tags"))[:-1]