Commit a38b5564e7e16bb4b225d7061390359fcf7ce17c
1 parent
a4397d39
Exists in
colab
and in
4 other branches
Set master as the default branch and renamed fetch branches to fetch
Signed-off-by: Pedro Scocco <pedroscocco@gmail.com>
Showing
2 changed files
with
13 additions
and
8 deletions
Show diff stats
app/assets/javascripts/repository/branch.js.coffee
| ... | ... | @@ -10,7 +10,7 @@ class Repository.Branch |
| 10 | 10 | |
| 11 | 11 | if option.value != "SVN" |
| 12 | 12 | $("#branches").show() |
| 13 | - @fetch_branches(document.getElementById("repository_address")) | |
| 13 | + @fetch(document.getElementById("repository_address")) | |
| 14 | 14 | else |
| 15 | 15 | $("#branches").hide() |
| 16 | 16 | |
| ... | ... | @@ -20,15 +20,19 @@ class Repository.Branch |
| 20 | 20 | @request = null |
| 21 | 21 | |
| 22 | 22 | # private method |
| 23 | - #fill_options = (options, el) -> | |
| 24 | 23 | fill_options: (options, el) -> |
| 24 | + default_branch = "master" | |
| 25 | + if default_branch in options | |
| 26 | + index = options.indexOf(default_branch) | |
| 27 | + options.splice(index, 1) | |
| 28 | + options.unshift(default_branch) | |
| 25 | 29 | for option in options |
| 26 | 30 | do -> |
| 27 | 31 | el.append($("<option></option>") |
| 28 | 32 | .attr("value", option) |
| 29 | 33 | .text(option)) |
| 30 | 34 | |
| 31 | - fetch_branches: (address_field) -> | |
| 35 | + fetch: (address_field) -> | |
| 32 | 36 | @cancel_request() |
| 33 | 37 | address = address_field.value |
| 34 | 38 | |
| ... | ... | @@ -49,7 +53,8 @@ class Repository.Branch |
| 49 | 53 | @request = $.get '/repository_branches', |
| 50 | 54 | {'url': address, 'scm_type': scm_type}, |
| 51 | 55 | (data) -> |
| 52 | - options = data["branches"] | |
| 53 | - if options != null | |
| 54 | - context.names[address] = options | |
| 55 | - context.fill_options(options, el) | |
| 56 | + unless data["errors"] | |
| 57 | + options = data["branches"] | |
| 58 | + if options != null | |
| 59 | + context.names[address] = options | |
| 60 | + context.fill_options(options, el) | ... | ... |
app/views/repositories/_form.html.erb
| ... | ... | @@ -55,7 +55,7 @@ |
| 55 | 55 | <div class="form-row"> |
| 56 | 56 | <div class="field-container"> |
| 57 | 57 | <%= f.label :address, class: 'control-label' %> |
| 58 | - <%= f.text_field :address, :required => true, class: 'text-field form-control', onchange: "_repository_branch.fetch_branches(this);" %> | |
| 58 | + <%= f.text_field :address, :required => true, class: 'text-field form-control', onchange: "_repository_branch.fetch(this);" %> | |
| 59 | 59 | </div> |
| 60 | 60 | <div class="help-container"> |
| 61 | 61 | <p> | ... | ... |