Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge c3d05d8 into 5fa12c5
Browse files Browse the repository at this point in the history
  • Loading branch information
zzet committed Mar 5, 2014
2 parents 5fa12c5 + c3d05d8 commit 23c8c19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
18 changes: 17 additions & 1 deletion lib/gitlab_git/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,11 @@ def decorate(commit, ref = nil)
def initialize(raw_commit, head = nil)
raise "Nil as raw commit passed" unless raw_commit

if raw_commit.is_a?(Hash)
case raw_commit
when Hash
init_from_hash(raw_commit)
when Rugged::Commit
init_from_rugged(raw_commit)
else
init_from_grit(raw_commit)
end
Expand Down Expand Up @@ -215,6 +218,19 @@ def ref_names(repo)

private

def init_from_rugged(rc)
@raw_commit = rc
@id = rc.oid
@message = rc.message
@authored_date = rc.author.time
@committed_date = rc.committer.time
@author_name = rc.author.name
@author_email = rc.author.email
@committer_name = rc.committer.name
@committer_email = rc.committer.email
@parent_ids = rc.parent_oids
end

def init_from_grit(grit)
@raw_commit = grit
@id = grit.id
Expand Down
10 changes: 8 additions & 2 deletions lib/gitlab_git/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,16 @@ def log(options)
)
end

# Delegate commits_between to Grit method
# Delegate commits_between to Rugged::Walker
#
def commits_between(from, to)
grit.commits_between(from, to)
walker = Rugged::Walker.new(rugged)
walker.sorting(Rugged::SORT_REVERSE)
walker.push(to)
walker.hide(from)
commits = walker.to_a # remove to_a for lazy enumerator
walker.reset
commits
end

def merge_base_commit(from, to)
Expand Down

0 comments on commit 23c8c19

Please sign in to comment.