Skip to content

Commit

Permalink
github_pr formatter fix: return empty patches object instead of []
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozuras committed Sep 28, 2014
1 parent 71d0962 commit 02edc49
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/pronto/git/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def diff(commit)
end

def show_commit(sha)
return [] unless sha
return empty_patches(sha) unless sha

commit = @repo.lookup(sha)
return [] if commit.parents.count != 1
return empty_patches(sha) if commit.parents.count != 1

# TODO: Rugged does not seem to support diffing against multiple parents
diff = commit.diff(reverse: true)
return [] if diff.nil?
return empty_patches(sha) if diff.nil?

Patches.new(self, sha, diff.patches)
end
Expand All @@ -52,6 +52,10 @@ def blame(patch, lineno)

private

def empty_patches(sha)
Patches.new(self, sha, [])
end

def merge_base(commit)
@repo.merge_base(commit, head)
end
Expand Down

0 comments on commit 02edc49

Please sign in to comment.