From 682f33a9bf5bb00c0c7887511ecc9f6ceeb0ec7d Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 13 Jun 2012 23:52:11 +0600 Subject: [PATCH] [refs #90] view merged status --- .../projects/pull_requests_controller.rb | 2 +- app/models/issue.rb | 6 +++--- app/models/pull_request.rb | 1 + app/views/projects/pull_requests/show.html.haml | 16 +++++++++------- config/locales/models/pull_request.en.yml | 3 +++ config/locales/models/pull_request.ru.yml | 5 ++++- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index f8202d5dd..c93e487d4 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -27,7 +27,7 @@ class Projects::PullRequestsController < Projects::BaseController end def create - @pull = @project.pull_requests.new(params[:pull_request]) # FIXME need validation! + @pull = @project.pull_requests.new(params[:pull_request]) @pull.issue.user, @pull.issue.project = current_user, @pull.base_project @pull.base_project, @pull.head_project = PullRequest.default_base_project(@project), @project diff --git a/app/models/issue.rb b/app/models/issue.rb index caa241a6a..6ee7a39f5 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -47,10 +47,10 @@ class Issue < ActiveRecord::Base closed_by && closed_at && status == 'closed' end - def set_close(closed_by) - self.closed_at = Time.now + def set_close(closed_by, status = 'closed') + self.closed_at = Time.now.utc self.closer = closed_by - self.status = 'closed' + self.status = status end def set_open diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index 62080ae15..63d63863b 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -95,6 +95,7 @@ class PullRequest < ActiveRecord::Base merging system("git push origin HEAD") system("git reset --hard HEAD") # for diff maybe FIXME + issue.set_close who, 'merged' end end end diff --git a/app/views/projects/pull_requests/show.html.haml b/app/views/projects/pull_requests/show.html.haml index 8f944d574..75370e7e6 100644 --- a/app/views/projects/pull_requests/show.html.haml +++ b/app/views/projects/pull_requests/show.html.haml @@ -30,9 +30,6 @@ .leftlist=t('activerecord.attributes.issue.body') .rightlist.pull_body=@pull.issue.body .both - .leftlist=t('activerecord.attributes.issue.status') - .rightlist=@pull.issue.status - .both - if can? :update, @pull.issue %br =link_to t('layout.edit'), '#', :id => 'edit_pull_content', :class => 'button' @@ -49,9 +46,14 @@ = render "projects/comments/list", :list => @issue.comments, :project => @project, :commentable => @issue %br = render "projects/comments/add", :project => @project, :commentable => @issue if current_user - - if can? :merge, @pull - %br - =form_for PullRequest.new, :url => merge_project_pull_request_path(@project, @pull), :html => { :method => :put, :class => :form } do |f| - =f.submit t 'projects.pull_requests.merge' + -if can? :update, @issue + - if can? :merge, @pull + %br + =form_for PullRequest.new, :url => merge_project_pull_request_path(@project, @pull), :html => { :method => :put, :class => :form } do |f| + =f.submit t 'projects.pull_requests.merge' + -else + .flash + -message = t("projects.pull_requests.#{@pull.status}", :user => @issue.closer.uname, :base_ref => @pull.base_ref, :head_ref => @pull.head_ref, :time => @issue.closed_at) + .alert="#{t 'activerecord.attributes.issue.status'}: #{raw message}" =render 'diff_commits_tabs' if @pull.status != 'already' diff --git a/config/locales/models/pull_request.en.yml b/config/locales/models/pull_request.en.yml index d699e1d9b..c803c50a3 100644 --- a/config/locales/models/pull_request.en.yml +++ b/config/locales/models/pull_request.en.yml @@ -14,6 +14,9 @@ en: duplicate: 'There is already a pull request for %{head_ref}' up_to_date: 'The %{base_ref} branch is already up-to-date with %{head_ref}' wrong_ref: Wrong tree-ish + block: This pull request cannot be automatically merged. + ready: This pull request can be automatically merged. + merged: '%{user} merged into %{base_ref} from %{head_ref} at %{time}' pull_requests: tabs: diff --git a/config/locales/models/pull_request.ru.yml b/config/locales/models/pull_request.ru.yml index c42382c44..9fe7c4177 100644 --- a/config/locales/models/pull_request.ru.yml +++ b/config/locales/models/pull_request.ru.yml @@ -10,10 +10,13 @@ ru: head_project: Проект-источник submit: Создать пул реквест update: Обновить коммиты - merge: Merge + merge: Мерж duplicate: 'Уже существует пул реквест %{head_ref}' up_to_date: 'Ветка %{base_ref} на данный момент уже содержит последние изменения %{head_ref}' wrong_ref: Неправильный tree-ish + block: Невозможно автоматически смержить данный пул реквест. + ready: Смержить данный пул реквест. + merged: '%{user} смержил %{base_ref} с %{head_ref} в %{time}' pull_requests: tabs: