Commit ed26ecae0c3303b5554b033abd6f0a078b7573c0
1 parent
0439387b
Exists in
master
and in
4 other branches
Add branches method to Repository role
Showing
1 changed file
with
9 additions
and
11 deletions
Show diff stats
app/roles/repository.rb
| @@ -45,8 +45,16 @@ module Repository | @@ -45,8 +45,16 @@ module Repository | ||
| 45 | File.exists?(hook_file) | 45 | File.exists?(hook_file) |
| 46 | end | 46 | end |
| 47 | 47 | ||
| 48 | + def branches | ||
| 49 | + repo.branches.collect(&:name).sort | ||
| 50 | + end | ||
| 51 | + | ||
| 48 | def tags | 52 | def tags |
| 49 | - repo.tags.map(&:name).sort.reverse | 53 | + repo.tags.collect(&:name).sort.reverse |
| 54 | + end | ||
| 55 | + | ||
| 56 | + def ref_names | ||
| 57 | + [branches + tags].flatten | ||
| 50 | end | 58 | end |
| 51 | 59 | ||
| 52 | def repo | 60 | def repo |
| @@ -79,14 +87,6 @@ module Repository | @@ -79,14 +87,6 @@ module Repository | ||
| 79 | @heads ||= repo.heads | 87 | @heads ||= repo.heads |
| 80 | end | 88 | end |
| 81 | 89 | ||
| 82 | - def branches_names | ||
| 83 | - heads.map(&:name) | ||
| 84 | - end | ||
| 85 | - | ||
| 86 | - def ref_names | ||
| 87 | - [branches_names + tags].flatten | ||
| 88 | - end | ||
| 89 | - | ||
| 90 | def tree(fcommit, path = nil) | 90 | def tree(fcommit, path = nil) |
| 91 | fcommit = commit if fcommit == :head | 91 | fcommit = commit if fcommit == :head |
| 92 | tree = fcommit.tree | 92 | tree = fcommit.tree |
| @@ -109,8 +109,6 @@ module Repository | @@ -109,8 +109,6 @@ module Repository | ||
| 109 | # - If two or more branches are present, returns the one that has a name | 109 | # - If two or more branches are present, returns the one that has a name |
| 110 | # matching root_ref (default_branch or 'master' if default_branch is nil) | 110 | # matching root_ref (default_branch or 'master' if default_branch is nil) |
| 111 | def discover_default_branch | 111 | def discover_default_branch |
| 112 | - branches = heads.collect(&:name) | ||
| 113 | - | ||
| 114 | if branches.length == 0 | 112 | if branches.length == 0 |
| 115 | nil | 113 | nil |
| 116 | elsif branches.length == 1 | 114 | elsif branches.length == 1 |