Commit f8c02f6e39d0a1f752583cc1942bb5e4c53df9c1

Authored by Robert Speicher
1 parent 2df3b310

Add branches and tags Repo methods

Simplifies the actions in RepositoriesController
app/controllers/repositories_controller.rb
... ... @@ -14,11 +14,11 @@ class RepositoriesController < ApplicationController
14 14 end
15 15  
16 16 def branches
17   - @branches = @project.repo.heads.sort_by(&:name)
  17 + @branches = @project.branches
18 18 end
19 19  
20 20 def tags
21   - @tags = @project.repo.tags.sort_by(&:name).reverse
  21 + @tags = @project.tags
22 22 end
23 23  
24 24 def archive
... ...
app/roles/repository.rb
... ... @@ -50,11 +50,21 @@ module Repository
50 50 repo.branches.collect(&:name).sort
51 51 end
52 52  
  53 + # Returns an Array of Branches
  54 + def branches
  55 + repo.branches.sort_by(&:name)
  56 + end
  57 +
53 58 # Returns an Array of tag names
54 59 def tag_names
55 60 repo.tags.collect(&:name).sort.reverse
56 61 end
57 62  
  63 + # Returns an Array of Tags
  64 + def tags
  65 + repo.tags.sort_by(&:name).reverse
  66 + end
  67 +
58 68 # Returns an Array of branch and tag names
59 69 def ref_names
60 70 [branch_names + tag_names].flatten
... ...