Skip to content

Commit

Permalink
allow the release number to be specified manually
Browse files Browse the repository at this point in the history
  • Loading branch information
sandlerr committed Aug 24, 2016
1 parent df1baef commit 894f152
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/controllers/releases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def index

def new
@release = @project.releases.build
@release.assign_release_number
end

def create
Expand All @@ -26,6 +27,6 @@ def create
private

def release_params
params.require(:release).permit(:commit).merge(author: current_user)
params.require(:release).permit(:commit, :number).merge(author: current_user)
end
end
2 changes: 0 additions & 2 deletions app/models/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ def self.find_by_version!(version)
find_by_number!(version[/\Av(\d+)\Z/, 1].to_i)
end

private

def assign_release_number
# Detect whether the number has been overwritten by params, e.g. using the
# release-number-from-ci plugin.
Expand Down
9 changes: 7 additions & 2 deletions app/views/releases/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
<section>
<fieldset>
<div class="row">
<p class="col-lg-offset-2 col-lg-4">Manual releases should only be created when your CI service is down, and you need to release a new version regardless. The commit will tagged as <%= @release.version %>, which will be pushed to the Git repository.</p>
<p class="col-lg-offset-2 col-lg-4">Manual releases should only be created when your CI service is down, and you need to release a new version regardless. The commit will be tagged and the tag will be pushed to the Git repository.</p>
</div>

<div class="form-group">
<%= form.label :commit, "SHA", class: "col-lg-2 control-label" %>
<div class="col-lg-4">
<%= form.text_field :commit, class: "form-control", value: @project.deploys.last.try(:commit) %>
<p class="help-block">This commit will be tagged with the version number <%= @release.version %>.</p>
</div>
</div>
<div class="form-group">
<%= form.label :number, "Release number", class: "col-lg-2 control-label" %>
<div class="col-lg-4">
<%= form.number_field :number, min: 1, step: 1, class: "form-control", value: @release.number %>
</div>
</div>

Expand Down

0 comments on commit 894f152

Please sign in to comment.