3 from stgit
.compat
import environ_get
4 from stgit
.config
import config
6 from .base
import Immutable
10 class Person(Immutable
):
11 """Represents an author or committer in a Git commit object.
13 Contains :attr:`name`, :attr:`email` and :attr:`timestamp`.
17 def __init__(self
, name
, email
, date
):
24 return '%s <%s>' % (self
.name
, self
.email
)
26 def set_name(self
, name
):
27 return self
._replace
(name
=name
)
29 def set_email(self
, email
):
30 return self
._replace
(email
=email
)
32 def set_date(self
, date
):
33 return self
._replace
(date
=date
)
35 def _replace(self
, **kws
):
37 kws
.get('name', self
.name
),
38 kws
.get('email', self
.email
),
39 kws
.get('date', self
.date
),
43 return '%s %s' % (self
.name_email
, self
.date
)
47 m
= re
.match(r
'^([^<]*)<([^>]*)>\s+(\d+\s+[+-]\d{4})$', s
)
48 name
= m
.group(1).strip()
50 date
= Date(m
.group(3))
51 return cls(name
, email
, date
)
55 if not hasattr(cls
, '_user'):
57 config
.get('user.name'), config
.get('user.email'), date
=None
63 if not hasattr(cls
, '_author'):
66 environ_get('GIT_AUTHOR_NAME', user
.name
),
67 environ_get('GIT_AUTHOR_EMAIL', user
.email
),
68 Date
.maybe(environ_get('GIT_AUTHOR_DATE')),
74 if not hasattr(cls
, '_committer'):
77 environ_get('GIT_COMMITTER_NAME', user
.name
),
78 environ_get('GIT_COMMITTER_EMAIL', user
.email
),
79 Date
.maybe(environ_get('GIT_COMMITTER_DATE')),