Commit f8c02f6e39d0a1f752583cc1942bb5e4c53df9c1
1 parent
2df3b310
Exists in
master
and in
4 other branches
Add branches and tags Repo methods
Simplifies the actions in RepositoriesController
Showing
2 changed files
with
12 additions
and
2 deletions
Show diff stats
app/controllers/repositories_controller.rb
| @@ -14,11 +14,11 @@ class RepositoriesController < ApplicationController | @@ -14,11 +14,11 @@ class RepositoriesController < ApplicationController | ||
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | def branches | 16 | def branches |
| 17 | - @branches = @project.repo.heads.sort_by(&:name) | 17 | + @branches = @project.branches |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | def tags | 20 | def tags |
| 21 | - @tags = @project.repo.tags.sort_by(&:name).reverse | 21 | + @tags = @project.tags |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | def archive | 24 | def archive |
app/roles/repository.rb
| @@ -50,11 +50,21 @@ module Repository | @@ -50,11 +50,21 @@ module Repository | ||
| 50 | repo.branches.collect(&:name).sort | 50 | repo.branches.collect(&:name).sort |
| 51 | end | 51 | end |
| 52 | 52 | ||
| 53 | + # Returns an Array of Branches | ||
| 54 | + def branches | ||
| 55 | + repo.branches.sort_by(&:name) | ||
| 56 | + end | ||
| 57 | + | ||
| 53 | # Returns an Array of tag names | 58 | # Returns an Array of tag names |
| 54 | def tag_names | 59 | def tag_names |
| 55 | repo.tags.collect(&:name).sort.reverse | 60 | repo.tags.collect(&:name).sort.reverse |
| 56 | end | 61 | end |
| 57 | 62 | ||
| 63 | + # Returns an Array of Tags | ||
| 64 | + def tags | ||
| 65 | + repo.tags.sort_by(&:name).reverse | ||
| 66 | + end | ||
| 67 | + | ||
| 58 | # Returns an Array of branch and tag names | 68 | # Returns an Array of branch and tag names |
| 59 | def ref_names | 69 | def ref_names |
| 60 | [branch_names + tag_names].flatten | 70 | [branch_names + tag_names].flatten |