summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-06-28 10:30:03 +0000
committerRémy Coutable <remy@rymai.me>2016-06-28 10:30:03 +0000
commit1897d75bdc8a661a8bba9ccfd4aba6e905556e2c (patch)
tree9cfc3410605703140d02fc9d1f281a3ff8fe4e97
parent2c3f3cb3920c5242cbc66456b3eed423636a2128 (diff)
parent8fb4c506e29cce8c14a5371e844c5d50fdfd5220 (diff)
downloadgitlab-ce-1897d75bdc8a661a8bba9ccfd4aba6e905556e2c.tar.gz
Merge branch 'display-deleted-ref-in-events' into 'master'
Display last commit of deleted branch in push events ## What does this MR do? Display the last commit of a deleted branch in the push events of a project. ## Are there points in the code the reviewer needs to double check? Is the change in `app/models/event.rb` the correct way to display a two-line event for deleted branches? ## Why was this MR needed? It is easier to restore an accidentally deleted branch if the commit hash is displayed in the push events. ## What are the relevant issue numbers? Fixes #18659 ## Screenshots ### Before garbage collection ![before-gc](/uploads/5674cd53e1564d48b7f2f8406ea0fbed/before-gc.png) ### After garbage collection ![after-gc](/uploads/80950c1932feeb3b69d0fc11b8f7acf4/after-gc.png) See merge request !4699
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/event.rb2
-rw-r--r--app/views/events/event/_push.html.haml25
3 files changed, 19 insertions, 9 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 9140e1a029f..1484edaceab 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.0 (unreleased)
- Replace Haml with Hamlit to make view rendering faster. !3666
- Wrap code blocks on Activies and Todos page. !4783 (winniehell)
+ - Display last commit of deleted branch in push events !4699 (winniehell)
- Add Sidekiq queue duration to transaction metrics.
- Make images fit to the size of the viewport !4810
- Fix check for New Branch button on Issue page !4630 (winniehell)
diff --git a/app/models/event.rb b/app/models/event.rb
index 716039fb54b..d7d23c7ae6d 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -315,7 +315,7 @@ class Event < ActiveRecord::Base
def body?
if push?
- push_with_commits?
+ push_with_commits? || rm_ref?
elsif note?
true
else
diff --git a/app/views/events/event/_push.html.haml b/app/views/events/event/_push.html.haml
index dc4ff17e31a..ea54ef226ec 100644
--- a/app/views/events/event/_push.html.haml
+++ b/app/views/events/event/_push.html.haml
@@ -1,3 +1,5 @@
+- project = event.project
+
.event-title
%span.author_name= link_to_author event
%span.event_label.pushed #{event.action_name} #{event.ref_type}
@@ -5,19 +7,18 @@
%strong= event.ref_name
- else
%strong
- = link_to event.ref_name, namespace_project_commits_path(event.project.namespace, event.project, event.ref_name), title: h(event.target_title)
+ = link_to event.ref_name, namespace_project_commits_path(project.namespace, project, event.ref_name), title: h(event.target_title)
at
- = link_to_project event.project
+ = link_to_project project
- if event.push_with_commits?
- - project = event.project
.event-body
%ul.well-list.event_commits
- few_commits = event.commits[0...2]
- few_commits.each do |commit|
= render "events/commit", commit: commit, project: project, event: event
- - create_mr = event.new_ref? && create_mr_button?(event.project.default_branch, event.ref_name, event.project)
+ - create_mr = event.new_ref? && create_mr_button?(project.default_branch, event.ref_name, project)
- if event.commits_count > 1
%li.commits-stat
- if event.commits_count > 2
@@ -27,18 +28,26 @@
- from = event.commit_from
- from_label = truncate_sha(from)
- else
- - from = event.project.default_branch
+ - from = project.default_branch
- from_label = from
- = link_to namespace_project_compare_path(event.project.namespace, event.project, from: from, to: event.commit_to) do
+ = link_to namespace_project_compare_path(project.namespace, project, from: from, to: event.commit_to) do
Compare #{from_label}...#{truncate_sha(event.commit_to)}
- if create_mr
%span{"data-user-is" => event.author_id, "data-display" => "inline"}
or
- = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
+ = link_to create_mr_path(project.default_branch, event.ref_name, project) do
create a merge request
- elsif create_mr
%li.commits-stat{"data-user-is" => event.author_id}
- = link_to create_mr_path(event.project.default_branch, event.ref_name, event.project) do
+ = link_to create_mr_path(project.default_branch, event.ref_name, project) do
Create Merge Request
+- elsif event.rm_ref?
+ - repository = project.repository
+ - last_commit = repository.commit(event.commit_from)
+ - if last_commit
+ .event-body
+ %ul.well-list.event_commits
+ = render "events/commit", commit: last_commit, project: project, event: event
+