@@ -451,96 +451,98 @@ hide_credentials = lambda x: ''.join(cre
def show_id(cs):
"""
Configurable function that shows ID
by default it's r123:fffeeefffeee
:param cs: changeset instance
from kallithea import CONFIG
def_len = safe_int(CONFIG.get('show_sha_length', 12))
show_rev = str2bool(CONFIG.get('show_revision_number', True))
raw_id = cs.raw_id[:def_len]
if show_rev:
return 'r%s:%s' % (cs.revision, raw_id)
else:
return '%s' % (raw_id)
def fmt_date(date):
if date:
_fmt = u"%a, %d %b %Y %H:%M:%S".encode('utf8')
return date.strftime(_fmt).decode('utf8')
return ""
def is_git(repository):
if hasattr(repository, 'alias'):
_type = repository.alias
elif hasattr(repository, 'repo_type'):
_type = repository.repo_type
_type = repository
return _type == 'git'
def is_hg(repository):
return _type == 'hg'
def email_or_none(author):
if not author:
return None
# extract email from the commit string
_email = email(author)
if _email:
# check it against Kallithea database, and use the MAIN email for this
# user
user = User.get_by_email(_email, case_insensitive=True, cache=True)
if user is not None:
return user.email
return _email
# See if it contains a username we can get an email from
user = User.get_by_username(author_name(author), case_insensitive=True,
cache=True)
# No valid email, not a valid user in the system, none!
def person(author, show_attr="username"):
# attr to return from fetched user
person_getter = lambda usr: getattr(usr, show_attr)
# if author is already an instance use it for extraction
if isinstance(author, User):
return person_getter(author)
# Valid email in the attribute passed, see if they're in the system
return person_getter(user)
# Maybe it's a username?
_author = author_name(author)
user = User.get_by_username(_author, case_insensitive=True,
# Still nothing? Just pass back the author name if any, else the email
return _author or _email
def person_by_id(id_, show_attr="username"):
Status change: