From 3af2ab9022fb09fb5b355f494e3def4dec00b265 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Thu, 7 Mar 2013 11:00:28 -0500 Subject: [PATCH] Handle when github api returns a null author, and other missing info --- .../javascripts/commits-widget.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/public/commits-widget/javascripts/commits-widget.js b/public/commits-widget/javascripts/commits-widget.js index 9964328b1f3..80d55c57031 100644 --- a/public/commits-widget/javascripts/commits-widget.js +++ b/public/commits-widget/javascripts/commits-widget.js @@ -39,11 +39,23 @@ $(function(){ var data = response.data; $.each(data, function(i, commit){ var $li = $('
  • ').appendTo( $commitsList ); - $('
    ').appendTo( $li ); - $right = $('
    ').appendTo( $li ); - $('' + commit.commit.message + '
    ').appendTo( $right ); - $('by ' + commit.committer.login + ' - ' + $.timeago(commit.commit.committer.date) + '').appendTo( $right ); - $('
    ').appendTo( $li ); + if( commit.sha && commit.commit && commit.commit.message && commit.commit.author && commit.commit.committer && commit.commit.committer.date ) { + if( commit.author && commit.author.gravatar_id ) { + $('
    ').appendTo( $li ); + } else { + $('
    ').appendTo( $li ); + } + $right = $('
    ').appendTo( $li ); + $('' + commit.commit.message + '
    ').appendTo( $right ); + $('by ' + commit.commit.author.name + ' - ' + $.timeago(commit.commit.committer.date) + '').appendTo( $right ); + $('
    ').appendTo( $li ); + } else { + // Render nothing. Or render a message: + // $('
     
    ').appendTo( $li ); + // $right = $('
    ').appendTo( $li ); + // $('this commit cannot be rendered').appendTo( $right ); + // $('
    ').appendTo( $li ); + } }); } });