@@ -434,97 +434,97 @@ 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', False))
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:
return date.strftime("%Y-%m-%d %H:%M:%S").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 user_or_none(author):
email = author_email(author)
if email is not None:
if email:
user = User.get_by_email(email, case_insensitive=True, cache=True)
if user is not None:
return user
user = User.get_by_username(author_name(author), case_insensitive=True, cache=True)
return None
def email_or_none(author):
if not author:
user = user_or_none(author)
return user.email # always use main email address - not necessarily the one used to find user
# extract email from the commit string
return email
# No valid email, not a valid user in the system, none!
def person(author, show_attr="username"):
"""Find the user identified by 'author', return one of the users attributes,
default to the username attribute, None if there is no user"""
# 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)
return person_getter(user)
# Still nothing? Just pass back the author name if any, else the email
return author_name(author) or email(author)
def person_by_id(id_, show_attr="username"):
#maybe it's an ID ?
Status change: