summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-01 16:04:35 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-01 16:04:35 +0300
commit49b024f5f5b88d406b895f050943db1e75adfa2a (patch)
tree65d9b34ebcaab38ecfc81da0acf0cc8e6c36d900 /lib
parentbb06e905efb1722502d71059c21add8cfde851aa (diff)
downloadgitlab-ce-49b024f5f5b88d406b895f050943db1e75adfa2a.tar.gz
Use Gitlab::Git:: for git features across application
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/git/commit.rb50
1 files changed, 10 insertions, 40 deletions
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 023672f986b..d7e1a5ca770 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -1,9 +1,9 @@
-# Gitlab::Git::Gitlab::Git::Commit is a wrapper around native Grit::Commit object
+# Gitlab::Git::Commit is a wrapper around native Grit::Commit object
# We dont want to use grit objects inside app/
# It helps us easily migrate to rugged in future
module Gitlab
module Git
- class Gitlab::Git::Commit
+ class Commit
attr_accessor :raw_commit, :head, :refs
delegate :message, :authored_date, :committed_date, :parents, :sha,
@@ -18,12 +18,12 @@ module Gitlab
repo.commits(root_ref).first
end
- Gitlab::Git::Commit.new(commit) if commit
+ Commit.new(commit) if commit
end
def fresh_commits(repo, n = 10)
commits = repo.heads.map do |h|
- repo.commits(h.name, n).map { |c| Gitlab::Git::Commit.new(c, h) }
+ repo.commits(h.name, n).map { |c| Commit.new(c, h) }
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
@@ -34,7 +34,7 @@ module Gitlab
end
def commits_with_refs(repo, n = 20)
- commits = repo.branches.map { |ref| Gitlab::Git::Commit.new(ref.commit, ref) }
+ commits = repo.branches.map { |ref| Commit.new(ref.commit, ref) }
commits.sort! do |x, y|
y.committed_date <=> x.committed_date
@@ -45,7 +45,7 @@ module Gitlab
def commits_since(repo, date)
commits = repo.heads.map do |h|
- repo.log(h.name, nil, since: date).each { |c| Gitlab::Git::Commit.new(c, h) }
+ repo.log(h.name, nil, since: date).each { |c| Commit.new(c, h) }
end.flatten.uniq { |c| c.id }
commits.sort! do |x, y|
@@ -62,41 +62,11 @@ module Gitlab
repo.commits(ref, limit, offset)
else
repo.commits(ref)
- end.map{ |c| Gitlab::Git::Commit.new(c) }
+ end.map{ |c| Commit.new(c) }
end
def commits_between(repo, from, to)
- repo.commits_between(from, to).map { |c| Gitlab::Git::Commit.new(c) }
- end
-
- def compare(project, from, to)
- result = {
- commits: [],
- diffs: [],
- commit: nil,
- same: false
- }
-
- return result unless from && to
-
- first = project.repository.commit(to.try(:strip))
- last = project.repository.commit(from.try(:strip))
-
- if first && last
- result[:same] = (first.id == last.id)
- result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Gitlab::Git::Commit.new(c)}
-
- # Dont load diff for 100+ commits
- result[:diffs] = if result[:commits].size > 100
- []
- else
- project.repo.diff(last.id, first.id) rescue []
- end
-
- result[:commit] = Gitlab::Git::Commit.new(first)
- end
-
- result
+ repo.commits_between(from, to).map { |c| Commit.new(c) }
end
end
@@ -142,7 +112,7 @@ module Gitlab
def prev_commit
@prev_commit ||= if parents.present?
- Gitlab::Git::Commit.new(parents.first)
+ Commit.new(parents.first)
else
nil
end
@@ -156,7 +126,7 @@ module Gitlab
#
# Cuts out the header and stats from #to_patch and returns only the diff.
def to_diff
- # see Grit::Gitlab::Git::Commit#show
+ # see Grit::Commit#show
patch = to_patch
# discard lines before the diff