Commit a165a0b23fd6cc81e7fc0163827310f69ce0399a
1 parent
d207a31f
Exists in
master
and in
4 other branches
Create event on dashboard when branch removed via UI
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
app/controllers/projects/branches_controller.rb
| ... | ... | @@ -14,7 +14,11 @@ class Projects::BranchesController < Projects::ApplicationController |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | 16 | def destroy |
| 17 | - @project.repository.rm_branch(params[:id]) | |
| 17 | + branch = @project.repository.branches.find { |branch| branch.name == params[:id] } | |
| 18 | + | |
| 19 | + if branch && @project.repository.rm_branch(branch.name) | |
| 20 | + Event.create_rm_branch(@project, current_user, branch) | |
| 21 | + end | |
| 18 | 22 | |
| 19 | 23 | respond_to do |format| |
| 20 | 24 | format.html { redirect_to project_branches_path } | ... | ... |
app/models/event.rb
| ... | ... | @@ -54,6 +54,19 @@ class Event < ActiveRecord::Base |
| 54 | 54 | Event::COMMENTED |
| 55 | 55 | end |
| 56 | 56 | end |
| 57 | + | |
| 58 | + def create_rm_branch(project, user, branch) | |
| 59 | + Event.create( | |
| 60 | + project: project, | |
| 61 | + action: Event::PUSHED, | |
| 62 | + data: { | |
| 63 | + ref: branch.name, | |
| 64 | + before: branch.commit.id, | |
| 65 | + after: '00000000' | |
| 66 | + }, | |
| 67 | + author_id: user.id | |
| 68 | + ) | |
| 69 | + end | |
| 57 | 70 | end |
| 58 | 71 | |
| 59 | 72 | def proper? | ... | ... |