Commit 4524ba20b804dacccbaca3c37e781adc82c5e0d3

Authored by Dmitriy Zaporozhets
1 parent 21191318

First step with rugged

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