Commit 4524ba20b804dacccbaca3c37e781adc82c5e0d3

Authored by Dmitriy Zaporozhets
1 parent 21191318

First step with rugged

@@ -22,6 +22,7 @@ gem 'omniauth-twitter' @@ -22,6 +22,7 @@ gem 'omniauth-twitter'
22 gem 'omniauth-github' 22 gem 'omniauth-github'
23 23
24 # Extracting information from a git repository 24 # Extracting information from a git repository
  25 +gem 'rugged', '~> 0.17.0.b7'
25 gem "gitlab-grit", '~> 1.0.0', require: 'grit' 26 gem "gitlab-grit", '~> 1.0.0', require: 'grit'
26 gem 'grit_ext', '~> 0.8.1' 27 gem 'grit_ext', '~> 0.8.1'
27 28
@@ -397,6 +397,7 @@ GEM @@ -397,6 +397,7 @@ GEM
397 ruby-progressbar (1.0.2) 397 ruby-progressbar (1.0.2)
398 rubyntlm (0.1.1) 398 rubyntlm (0.1.1)
399 rubyzip (0.9.9) 399 rubyzip (0.9.9)
  400 + rugged (0.17.0.b7)
400 sanitize (2.0.3) 401 sanitize (2.0.3)
401 nokogiri (>= 1.4.4, < 1.6) 402 nokogiri (>= 1.4.4, < 1.6)
402 sass (3.2.7) 403 sass (3.2.7)
@@ -565,6 +566,7 @@ DEPENDENCIES @@ -565,6 +566,7 @@ DEPENDENCIES
565 redcarpet (~> 2.2.2) 566 redcarpet (~> 2.2.2)
566 redis-rails 567 redis-rails
567 rspec-rails 568 rspec-rails
  569 + rugged (~> 0.17.0.b7)
568 sass-rails (~> 3.2.5) 570 sass-rails (~> 3.2.5)
569 sdoc 571 sdoc
570 seed-fu 572 seed-fu
app/models/repository.rb
@@ -34,6 +34,10 @@ class Repository @@ -34,6 +34,10 @@ class Repository
34 @repo ||= Grit::Repo.new(path_to_repo) 34 @repo ||= Grit::Repo.new(path_to_repo)
35 end 35 end
36 36
  37 + def rugged
  38 + @rugged ||= Rugged::Repository.new(path_to_repo)
  39 + end
  40 +
37 def commit(commit_id = nil) 41 def commit(commit_id = nil)
38 Commit.find_or_first(repo, commit_id, root_ref) 42 Commit.find_or_first(repo, commit_id, root_ref)
39 end 43 end
@@ -64,17 +68,17 @@ class Repository @@ -64,17 +68,17 @@ class Repository
64 68
65 # Returns an Array of branch names 69 # Returns an Array of branch names
66 def branch_names 70 def branch_names
67 - repo.branches.collect(&:name).sort 71 + branches.map(&:name).sort
68 end 72 end
69 73
70 # Returns an Array of Branches 74 # Returns an Array of Branches
71 def branches 75 def branches
72 - repo.branches.sort_by(&:name) 76 + rugged.branches.sort_by(&:name)
73 end 77 end
74 78
75 # Returns an Array of tag names 79 # Returns an Array of tag names
76 def tag_names 80 def tag_names
77 - repo.tags.collect(&:name).sort.reverse 81 + rugged.tags.sort.reverse
78 end 82 end
79 83
80 # Returns an Array of Tags 84 # Returns an Array of Tags