(project_name, j, config)
Create and yield a one-line summary of each commit in `j`.
Create and yield a one-line summary of each commit in `j`.
Create and yield a one - line summary of each commit in j .
def _create_commit_summary(project_name, j, config):
    """
    Create and yield a one-line summary of each commit in `j`.
    """
    prefer_username = config.get('prefer_username', True)
    title_only = config.get('title_only', False)

    original = j['original']

    for commit in original['commits']:
        if config.get('distinct_only', True):
            if not commit['distinct']:
                # This commit has been seen in the repo
                # before, skip over it and to the next one
                continue

        committer = commit.get('committer', {})
        author = commit.get('author', {})

        line = []

        line.append(u'{RESET}[{BLUE}{name}{RESET}]'.format(
            name=project_name,
            **HookService.colors
        ))

        # Show the committer.
        attribute_to = None
        if prefer_username:
            attribute_to = author.get('username')
            if attribute_to is None:
                attribute_to = author.get('username')

        if attribute_to is None:
            attribute_to = author.get('name')
            if attribute_to is None:
                attribute_to = committer.get('name')

        if attribute_to:
            line.append(u'{ORANGE}{attribute_to}{RESET}'.format(
                attribute_to=attribute_to,
                **HookService.colors
            ))

        line.append(u'{GREEN}{sha}{RESET}'.format(
            sha=commit['id'][:7],
            **HookService.colors
        ))

        line.append(u'-')

        message = commit['message']
        message_lines = message.split('\n')
        if title_only and len(message_lines) > 0:
            message = message_lines[0]
        # Cap the commit message to 1000 characters, this should be around two
        # lines on IRC and stops really long messages from spamming channels.
        if len(message) > COMMIT_MESSAGE_LENGTH_LIMIT:
            message = message[:COMMIT_MESSAGE_LENGTH_LIMIT] + '...'
        line.append(message)

        yield u' '.join(line)
def _create_commit_summary ( project_name , j , config ) : prefer_username = config . get ( 'prefer_username' , True ) title_only = config . get ( 'title_only' , False ) original = j [ 'original' ] for commit in original [ 'commits' ] : if config . get ( 'distinct_only' , True ) : if not commit [ 'distinct' ] : # This commit has been seen in the repo # before, skip over it and to the next one continue committer = commit . get ( 'committer' , { } ) author = commit . get ( 'author' , { } ) line = [ ] line . append ( u'{RESET}[{BLUE}{name}{RESET}]' . format ( name = project_name , * * HookService . colors ) ) # Show the committer. attribute_to = None if prefer_username : attribute_to = author . get ( 'username' ) if attribute_to is None : attribute_to = author . get ( 'username' ) if attribute_to is None : attribute_to = author . get ( 'name' ) if attribute_to is None : attribute_to = committer . get ( 'name' ) if attribute_to : line . append ( u'{ORANGE}{attribute_to}{RESET}' . format ( attribute_to = attribute_to , * * HookService . colors ) ) line . append ( u'{GREEN}{sha}{RESET}' . format ( sha = commit [ 'id' ] [ : 7 ] , * * HookService . colors ) ) line . append ( u'-' ) message = commit [ 'message' ] message_lines = message . split ( '\n' ) if title_only and len ( message_lines ) > 0 : message = message_lines [ 0 ] # Cap the commit message to 1000 characters, this should be around two # lines on IRC and stops really long messages from spamming channels. if len ( message ) > COMMIT_MESSAGE_LENGTH_LIMIT : message = message [ : COMMIT_MESSAGE_LENGTH_LIMIT ] + '...' line . append ( message ) yield u' ' . join ( line )