This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 2ec12c9b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Impoved merge requests show page. Minor style improvements across project

parent aaacf834e8f1
......@@ -41,6 +41,10 @@ a:focus {
.label {
background-color: #474D57;
&.pushed {
background-color: $link_color;
}
}
.pretty_label {
......@@ -865,7 +869,7 @@ p.time {
}
}
padding: 10px 5px;
padding: 15px 5px;
border-bottom: 1px solid #eee;
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
&:last-child { border:none }
......@@ -963,3 +967,17 @@ p.time {
.highlight_word {
background:#EEDC94;
}
.status_info {
font-size:14px;
padding:5px 15px;
line-height:24px;
width:60px;
text-align:center;
float:left;
margin-right:20px;
}
.merge_request_status_holder {
margin-bottom:20px;
}
......@@ -45,9 +45,6 @@ def show
# or from cache if already merged
@commits = @merge_request.commits
# Close MR if nothing to merge
#@merge_request.mark_as_merged! if @merge_request.probably_merged?
respond_to do |format|
format.html
format.js
......@@ -75,8 +72,7 @@ def create
respond_to do |format|
if @merge_request.save
@merge_request.reloaded_commits
@merge_request.reloaded_diffs
@merge_request.reload_code
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully created.' }
format.json { render json: @merge_request, status: :created, location: @merge_request }
else
......@@ -89,6 +85,7 @@ def create
def update
respond_to do |format|
if @merge_request.update_attributes(params[:merge_request].merge(:author_id_of_changes => current_user.id))
@merge_request.reload_code
format.html { redirect_to [@project, @merge_request], notice: 'Merge request was successfully updated.' }
format.json { head :ok }
else
......
......@@ -41,12 +41,21 @@ def self.search query
where("title like :query", :query => "%#{query}%")
end
def self.find_all_by_branch(branch_name)
where("source_branch like :branch or target_branch like :branch", :branch => branch_name)
end
def validate_branches
if target_branch == source_branch
errors.add :base, "You can not use same branch for source and target branches"
end
end
def reload_code
self.reloaded_commits
self.reloaded_diffs
end
def new?
today? && created_at == updated_at
end
......@@ -72,10 +81,19 @@ def last_commit
commits.first
end
def merged?
merged && merge_event
end
def merge_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Merged).last
end
def closed_event
self.project.events.where(:target_id => self.id, :target_type => "MergeRequest", :action => Event::Closed).last
end
# Return the number of +1 comments (upvotes)
def upvotes
notes.select(&:upvote?).size
......@@ -115,6 +133,17 @@ def unmerged_commits
sort_by(&:created_at).
reverse
end
def merge!(user_id)
self.mark_as_merged!
Event.create(
:project => self.project,
:action => Event::Merged,
:target_id => self.id,
:target_type => "MergeRequest",
:author_id => user_id
)
end
end
# == Schema Information
#
......
......@@ -80,35 +80,18 @@ def observe_push(oldrev, newrev, ref, author_key_id)
def update_merge_requests(oldrev, newrev, ref, author_key_id)
return true unless ref =~ /heads/
branch_name = ref.gsub("refs/heads/", "")
key = Key.find_by_identifier(author_key_id)
user = key.user
user = Key.find_by_identifier(author_key_id).user
c_ids = self.commits_between(oldrev, newrev).map(&:id)
# update commits & diffs for existing MR
mrs = self.merge_requests.opened.where(:source_branch => branch_name).all
mrs.each do |merge_request|
merge_request.reloaded_commits
merge_request.reloaded_diffs
end
# Update code for merge requests
mrs = self.merge_requests.opened.find_all_by_branch(branch_name).all
mrs.each { |merge_request| merge_request.reload_code }
# Close merge requests
mrs = self.merge_requests.opened.where(:target_branch => branch_name).all
mrs.each do |merge_request|
next unless merge_request.last_commit
# Mark as merged & create event if merged
if c_ids.include?(merge_request.last_commit.id)
merge_request.mark_as_merged!
Event.create(
:project => self,
:action => Event::Merged,
:target_id => merge_request.id,
:target_type => "MergeRequest",
:author_id => user.id
)
end
end
mrs = mrs.select(&:last_commit).select { |mr| c_ids.include?(mr.last_commit.id) }
mrs.each { |merge_request| merge_request.merge!(user.id) }
true
end
......
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
- if event.closed?
closed
- else
reopened
issue
%span.label.important
- if event.closed?
closed
- else
reopened
 issue
= link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title
at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
- if event.closed?
closed
- else
reopened
merge request
%span.label.important
- if event.closed?
closed
- else
reopened
 merge request
= link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title
at
......@@ -12,7 +13,6 @@ at
%span.cgray
= time_ago_in_words(event.created_at)
ago.
%br
%span.label= event.merge_request.source_branch
→
%span.label= event.merge_request.target_branch
......
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
created new issue
%span.label.success created
 new issue
= link_to project_issue_path(event.project, event.issue) do
%strong= truncate event.issue_title
at
......
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
requested merge
%span.label.success requested
 merge
= link_to project_merge_request_path(event.project, event.merge_request) do
%strong= truncate event.merge_request_title
at
......@@ -8,7 +9,6 @@ at
%span.cgray
= time_ago_in_words(event.created_at)
ago.
%br
%span.label= event.merge_request.source_branch
→
%span.label= event.merge_request.target_branch
......
- if event.new_branch? || event.new_tag?
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
pushed new
%span.label.pushed pushed
 new
- if event.new_tag?
tag
= link_to project_commits_path(event.project, :ref => event.tag_name) do
......@@ -18,7 +19,8 @@
- else
= image_tag gravatar_icon(event.author_email), :class => "avatar"
%strong #{event.author_name}
pushed to
%span.label.pushed pushed
 to
= link_to project_commits_path(event.project, :ref => event.branch_name) do
%strong= event.branch_name
at
......@@ -30,10 +32,10 @@
= link_to compare_project_commits_path(event.project, :from => event.commits.first.prev_commit_id, :to => event.commits.last.id) do
Compare #{event.commits.first.commit.id[0..8]}...#{event.commits.last.id[0..8]}
- @project = event.project
%ul.unstyled
- if event.commits.size > 4
= render event.commits[0..2]
%li ... and #{event.commits.size - 3} more commits
%ul.unstyled.event_commits
- if event.commits.size > 3
= render event.commits[0...2]
%li ... and #{event.commits.size - 2} more commits
- else
= render event.commits
......
......@@ -15,7 +15,7 @@
- if issue.today?
%span.label.success today
- if issue.notes.any?
%span.label= pluralize issue.notes.count, 'note'
%span.pretty_label= pluralize issue.notes.count, 'note'
- if issue.upvotes > 0
%span.label.success= "+#{issue.upvotes}"
......
......@@ -15,7 +15,7 @@
:javascript
$(function(){
var modal = $('#modal_merge_info').modal({modal: true});
$('.info_link').bind("click", function(){
$('.how_to_merge_link').bind("click", function(){
modal.show();
});
$('.modal-header .close').bind("click", function(){
......
......@@ -6,7 +6,7 @@
= time_ago_in_words(merge_request.created_at)
ago
- if merge_request.notes.any?
%span.label= pluralize merge_request.notes.count, 'note'
%span.pretty_label= pluralize merge_request.notes.count, 'note'
- if merge_request.upvotes > 0
%span.label.success= "+#{merge_request.upvotes}"
.right
......
......@@ -26,23 +26,23 @@
%hr
- if @merge_request.closed
.alert-message.error Closed
- if @merge_request.merged
- event = @merge_request.merge_event
%div
%p
%strong #{event.author_name}
merged this request
%span.cgray
= time_ago_in_words(event.created_at)
ago.
%br
- else
.alert-message.success
= link_to "#", :class => "info_link", :title => "How To Merge" do
= image_tag "Info-UI.PNG"
Open
.merge_request_status_holder
- if @merge_request.closed
%h5
.alert-message.error.status_info Closed
- if @merge_request.merged?
%span
Merged by #{@merge_request.merge_event.author_name}
%small #{time_ago_in_words(@merge_request.merge_event.created_at)} ago.
- elsif @merge_request.closed_event
%span
Closed by #{@merge_request.closed_event.author_name}
%small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago.
%br
- else
%h5
.alert-message.success.status_info Open
= link_to "How to merge", "#", :class => "vlink how_to_merge_link", :title => "How To Merge"
= render "merge_requests/how_to_merge"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment