| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,15 +27,17 @@ def _init_externals(): | |||
| 27 | 27 | from git.config import GitConfigParser | |
| 28 | 28 | from git.objects import * | |
| 29 | 29 | from git.refs import * | |
| 30 | - from git.actor import Actor | ||
| 31 | 30 | from git.diff import * | |
| 32 | 31 | from git.errors import InvalidGitRepositoryError, NoSuchPathError, GitCommandError | |
| 33 | 32 | from git.cmd import Git | |
| 34 | 33 | from git.repo import Repo | |
| 35 | - from git.stats import Stats | ||
| 36 | 34 | from git.remote import * | |
| 37 | 35 | from git.index import * | |
| 38 | - from git.utils import LockFile, BlockingLockFile | ||
| 36 | + from git.utils import ( | ||
| 37 | + LockFile, | ||
| 38 | + BlockingLockFile, | ||
| 39 | + Stats | ||
| 40 | + ) | ||
| 39 | 41 | ||
| 40 | 42 | #} END imports | |
| 41 | 43 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | from tree import * | |
| 9 | 9 | from commit import * | |
| 10 | 10 | from submodule import * | |
| 11 | + from utils import Actor | ||
| 11 | 12 | ||
| 12 | 13 | __all__ = [ name for name, obj in locals().items() | |
| 13 | 14 | if not (name.startswith('_') or inspect.ismodule(obj)) ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,10 +4,12 @@ | |||
| 4 | 4 | # This module is part of GitPython and is released under | |
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | ||
| 7 | - from git.utils import Iterable | ||
| 7 | + from git.utils import ( | ||
| 8 | + Iterable, | ||
| 9 | + Stats, | ||
| 10 | + ) | ||
| 11 | + | ||
| 8 | 12 | import git.diff as diff | |
| 9 | - import git.stats as stats | ||
| 10 | - from git.actor import Actor | ||
| 11 | 13 | from tree import Tree | |
| 12 | 14 | from gitdb import IStream | |
| 13 | 15 | from cStringIO import StringIO | |
@@ -223,7 +225,7 @@ def stats(self): | |||
| 223 | 225 | text = text2 | |
| 224 | 226 | else: | |
| 225 | 227 | text = self.repo.git.diff(self.parents[0].sha, self.sha, '--', numstat=True) | |
| 226 | - return stats.Stats._list_from_string(self.repo, text) | ||
| 228 | + return Stats._list_from_string(self.repo, text) | ||
| 227 | 229 | ||
| 228 | 230 | @classmethod | |
| 229 | 231 | def _iter_from_process_or_stream(cls, repo, proc_or_stream): | |
@@ -332,8 +334,8 @@ def create_from_tree(cls, repo, tree, message, parent_commits=None, head=False): | |||
| 332 | 334 | enc_section, enc_option = cls.conf_encoding.split('.') | |
| 333 | 335 | conf_encoding = cr.get_value(enc_section, enc_option, cls.default_encoding) | |
| 334 | 336 | ||
| 335 | - author = Actor(author_name, author_email) | ||
| 336 | - committer = Actor(committer_name, committer_email) | ||
| 337 | + author = utils.Actor(author_name, author_email) | ||
| 338 | + committer = utils.Actor(committer_name, committer_email) | ||
| 337 | 339 | ||
| 338 | 340 | ||
| 339 | 341 | # CREATE NEW COMMIT | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,6 @@ | |||
| 8 | 8 | """ | |
| 9 | 9 | import re | |
| 10 | 10 | from collections import deque as Deque | |
| 11 | - from git.actor import Actor | ||
| 12 | 11 | import platform | |
| 13 | 12 | ||
| 14 | 13 | from string import digits | |
@@ -19,6 +18,8 @@ | |||
| 19 | 18 | 'ProcessStreamAdapter', 'Traversable', 'altz_to_utctz_str', 'utctz_to_altz', | |
| 20 | 19 | 'verify_utctz') | |
| 21 | 20 | ||
| 21 | + #{ Functions | ||
| 22 | + | ||
| 22 | 23 | def get_object_type_by_name(object_type_name): | |
| 23 | 24 | """ | |
| 24 | 25 | Returns | |
@@ -180,6 +181,60 @@ def parse_actor_and_date(line): | |||
| 180 | 181 | actor, epoch, offset = m.groups() | |
| 181 | 182 | return (Actor._from_string(actor), int(epoch), utctz_to_altz(offset)) | |
| 182 | 183 | ||
| 184 | + | ||
| 185 | + #} END functions | ||
| 186 | + | ||
| 187 | + | ||
| 188 | + #{ Classes | ||
| 189 | + | ||
| 190 | + class Actor(object): | ||
| 191 | + """Actors hold information about a person acting on the repository. They | ||
| 192 | + can be committers and authors or anything with a name and an email as | ||
| 193 | + mentioned in the git log entries.""" | ||
| 194 | + # precompiled regex | ||
| 195 | + name_only_regex = re.compile( r'<(.+)>' ) | ||
| 196 | + name_email_regex = re.compile( r'(.*) <(.+?)>' ) | ||
| 197 | + | ||
| 198 | + def __init__(self, name, email): | ||
| 199 | + self.name = name | ||
| 200 | + self.email = email | ||
| 201 | + | ||
| 202 | + def __eq__(self, other): | ||
| 203 | + return self.name == other.name and self.email == other.email | ||
| 204 | + | ||
| 205 | + def __ne__(self, other): | ||
| 206 | + return not (self == other) | ||
| 207 | + | ||
| 208 | + def __hash__(self): | ||
| 209 | + return hash((self.name, self.email)) | ||
| 210 | + | ||
| 211 | + def __str__(self): | ||
| 212 | + return self.name | ||
| 213 | + | ||
| 214 | + def __repr__(self): | ||
| 215 | + return '<git.Actor "%s <%s>">' % (self.name, self.email) | ||
| 216 | + | ||
| 217 | + @classmethod | ||
| 218 | + def _from_string(cls, string): | ||
| 219 | + """Create an Actor from a string. | ||
| 220 | + :param string: is the string, which is expected to be in regular git format | ||
| 221 | + | ||
| 222 | + John Doe <jdoe@example.com> | ||
| 223 | + | ||
| 224 | + :return: Actor """ | ||
| 225 | + m = cls.name_email_regex.search(string) | ||
| 226 | + if m: | ||
| 227 | + name, email = m.groups() | ||
| 228 | + return Actor(name, email) | ||
| 229 | + else: | ||
| 230 | + m = cls.name_only_regex.search(string) | ||
| 231 | + if m: | ||
| 232 | + return Actor(m.group(1), None) | ||
| 233 | + else: | ||
| 234 | + # assume best and use the whole string as name | ||
| 235 | + return Actor(string, None) | ||
| 236 | + # END special case name | ||
| 237 | + # END handle name/email matching | ||
| 183 | 238 | ||
| 184 | 239 | ||
| 185 | 240 | class ProcessStreamAdapter(object): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 7 | from errors import InvalidGitRepositoryError, NoSuchPathError | |
| 8 | 8 | from cmd import Git | |
| 9 | - from actor import Actor | ||
| 9 | + from objects import Actor | ||
| 10 | 10 | from refs import * | |
| 11 | 11 | from index import IndexFile | |
| 12 | 12 | from objects import * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments