From 94029c3cda384f90f7764661b7c0251f54a39811 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Wed, 3 Oct 2012 17:36:04 +0600 Subject: [PATCH] [refs #90] base -> to, head -> from --- app/assets/javascripts/extra/pull.js | 8 +-- app/assets/stylesheets/design/custom.scss | 4 +- .../projects/pull_requests_controller.rb | 48 +++++++------- app/helpers/pull_request_helper.rb | 8 +-- app/models/ability.rb | 10 +-- app/models/project.rb | 2 +- app/models/pull_request.rb | 64 +++++++++---------- .../projects/projects/refs_list.html.haml | 2 +- .../projects/pull_requests/new.html.haml | 12 ++-- config/locales/models/pull_request.en.yml | 16 ++--- config/locales/models/pull_request.ru.yml | 16 ++--- config/routes.rb | 2 +- ...81546_rename_base_head_in_pull_requests.rb | 10 +++ db/schema.rb | 14 ++-- 14 files changed, 112 insertions(+), 104 deletions(-) create mode 100644 db/migrate/20121003081546_rename_base_head_in_pull_requests.rb diff --git a/app/assets/javascripts/extra/pull.js b/app/assets/javascripts/extra/pull.js index 92dad8209..b69eeb18e 100644 --- a/app/assets/javascripts/extra/pull.js +++ b/app/assets/javascripts/extra/pull.js @@ -2,12 +2,12 @@ $(document).ready(function() { var upd_action = $('#update_action').val(); var form = $('#new_pull_request'); - $('#pull_request_base_project').on('autocompleteselect', function(event, data){ - var ref = $('#base_ref'); - ref.parent().load(data.item.get_refs_url+' #base_ref', {"selected": ref.val()}); + $('#pull_request_to_project').on('autocompleteselect', function(event, data){ + var ref = $('#to_ref'); + ref.parent().load(data.item.get_refs_url+' #to_ref', {"selected": ref.val()}); }); - $('#pull_request_base_project, input#base_refs, input#head_refs').on('autocompleteselect', function(event, data){ + $('#pull_request_to_project, input#to_refs, input#from_refs').on('autocompleteselect', function(event, data){ form.attr('action', upd_action) .attr('method', 'get'); $('#update_pull').fadeIn('fast'); diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 1cf5db3de..a7850bd2a 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1571,8 +1571,6 @@ table.tablesorter.platform-maintainers.static-search thead tr.search th input[ty .edit_comment .comment-left { margin-top: 0; } - - } #open-comment > h3.tmargin0 { @@ -1647,7 +1645,7 @@ form#new_pull_request { } } -#repo-wrapper form#new_pull_request .wrapper { +#repo-wrapper form#new_pull_request .wrapper { background: none; border: none; height: 36px; diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 85bfb8a4a..8227dde42 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -4,24 +4,24 @@ class Projects::PullRequestsController < Projects::BaseController skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :project - load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :except => [:index, :autocomplete_base_project] - load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index, :autocomplete_base_project] + load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :except => [:index, :autocomplete_to_project] + load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index, :autocomplete_to_project] def new - base_project = set_base_project(false) - authorize! :read, base_project + to_project = set_to_project(false) + authorize! :read, to_project - @pull = base_project.pull_requests.new - @pull.issue = base_project.issues.new + @pull = to_project.pull_requests.new + @pull.issue = to_project.issues.new set_attrs - if PullRequest.check_ref(@pull, 'base', @pull.base_ref) && PullRequest.check_ref(@pull, 'head', @pull.head_ref) || @pull.uniq_merge + if PullRequest.check_ref(@pull, 'base', @pull.to_ref) && PullRequest.check_ref(@pull, 'head', @pull.from_ref) || @pull.uniq_merge flash.now[:warning] = @pull.errors.full_messages.join('. ') else @pull.check(false) # don't make event transaction if @pull.already? @pull.destroy - flash.now[:warning] = I18n.t('projects.pull_requests.up_to_date', :base_ref => @pull.base_ref, :head_ref => @pull.head_ref) + flash.now[:warning] = I18n.t('projects.pull_requests.up_to_date', :to_ref => @pull.to_ref, :from_ref => @pull.from_ref) else load_diff_commits_data end @@ -33,28 +33,28 @@ class Projects::PullRequestsController < Projects::BaseController raise 'expect pull_request params' # for debug redirect :back end - base_project = set_base_project - authorize! :read, base_project + to_project = set_to_project + authorize! :read, to_project - @pull = base_project.pull_requests.new pull_params - @pull.issue.user, @pull.issue.project, @pull.head_project = current_user, base_project, @project + @pull = to_project.pull_requests.new pull_params + @pull.issue.user, @pull.issue.project, @pull.from_project = current_user, to_project, @project if @pull.valid? # FIXME more clean/clever logics @pull.save # set pull id @pull.check(false) # don't make event transaction if @pull.already? @pull.destroy - flash.now[:error] = I18n.t('projects.pull_requests.up_to_date', :base_ref => @pull.base_ref, :head_ref => @pull.head_ref) + flash.now[:error] = I18n.t('projects.pull_requests.up_to_date', :to_ref => @pull.to_ref, :from_ref => @pull.from_ref) render :new else @pull.send(@pull.status) - redirect_to project_pull_request_path(@pull.base_project, @pull) + redirect_to project_pull_request_path(@pull.to_project, @pull) end else flash.now[:error] = t('flash.pull_request.save_error') flash.now[:warning] = @pull.errors.full_messages.join('. ') - if @pull.errors.try(:messages) && @pull.errors.messages[:base_ref].nil? && @pull.errors.messages[:head_ref].nil? + if @pull.errors.try(:messages) && @pull.errors.messages[:to_ref].nil? && @pull.errors.messages[:from_ref].nil? @pull.check(false) # don't make event transaction load_diff_commits_data end @@ -70,7 +70,7 @@ class Projects::PullRequestsController < Projects::BaseController @pull.check if @pull.open? end end - redirect_to project_pull_request_path(@pull.base_project, @pull) + redirect_to project_pull_request_path(@pull.to_project, @pull) end def merge @@ -79,7 +79,7 @@ class Projects::PullRequestsController < Projects::BaseController flash.now[:error] = t('flash.pull_request.save_error') flash.now[:warning] = @pull.errors.full_messages.join('. ') end - redirect_to project_pull_request_path(@pull.base_project, @pull) + redirect_to project_pull_request_path(@pull.to_project, @pull) end def show @@ -107,7 +107,7 @@ class Projects::PullRequestsController < Projects::BaseController end end - def autocomplete_base_project + def autocomplete_to_project items = Project.accessible_by(current_ability, :membered) | @project.ancestors items.select! {|e| Regexp.new(params[:term].downcase).match(e.name_with_owner.downcase) && e.repo.branches.count > 0} render :json => json_for_autocomplete_base(items) @@ -132,7 +132,7 @@ class Projects::PullRequestsController < Projects::BaseController @base_commit = @pull.common_ancestor @head_commit = repo.commits(@pull.head_branch).first - @commits = repo.commits_between(repo.commits(@pull.base_ref).first, @head_commit) + @commits = repo.commits_between(repo.commits(@pull.to_ref).first, @head_commit) @total_commits = @commits.count @commits = @commits.last(100) @@ -140,8 +140,8 @@ class Projects::PullRequestsController < Projects::BaseController @stats = @pull.diff_stats repo, @base_commit, @head_commit end - def set_base_project bang=true - args = params[:base_project].try(:split, '/') || [] + def set_to_project bang=true + args = params[:to_project].try(:split, '/') || [] if bang raise ActiveRecord::RecordNotFound if args.length != 2 Project.find_by_owner_and_name! *args @@ -156,8 +156,8 @@ class Projects::PullRequestsController < Projects::BaseController @pull.issue.title = pull_params[:issue_attributes][:title].presence @pull.issue.body = pull_params[:issue_attributes][:body].presence end - @pull.head_project = @project - @pull.base_ref = (pull_params[:base_ref].presence if pull_params) || @pull.base_project.default_branch - @pull.head_ref = params[:treeish].presence || (pull_params[:head_ref].presence if pull_params) || @pull.head_project.default_branch + @pull.from_project = @project + @pull.to_ref = (pull_params[:to_ref].presence if pull_params) || @pull.to_project.default_branch + @pull.from_ref = params[:treeish].presence || (pull_params[:from_ref].presence if pull_params) || @pull.from_project.default_branch end end diff --git a/app/helpers/pull_request_helper.rb b/app/helpers/pull_request_helper.rb index d990b0ad3..cfc0e9ce3 100644 --- a/app/helpers/pull_request_helper.rb +++ b/app/helpers/pull_request_helper.rb @@ -13,8 +13,8 @@ module PullRequestHelper def pull_status pull if %w(blocked merged closed ready open).include? pull.status - t("projects.pull_requests.#{pull.status}", :user => pull.issue.closer.try(:uname), :base_ref => show_ref(pull, 'base'), - :head_ref => show_ref(pull, 'head'), :time => pull.issue.closed_at).html_safe + t("projects.pull_requests.#{pull.status}", :user => pull.issue.closer.try(:uname), :to_ref => show_ref(pull, 'to'), + :from_ref => show_ref(pull, 'from'), :time => pull.issue.closed_at).html_safe else raise "pull id (#{pull.id}) wrong status #{pull.status} " end @@ -22,9 +22,9 @@ module PullRequestHelper def pull_header pull str = "#{t '.header'} #{t 'from'} \ - #{show_ref pull, 'head'} \ + #{show_ref pull, 'from'} \ #{t 'into'} \ - #{show_ref pull, 'base'}" + #{show_ref pull, 'to'}" str << " #{t 'by'} #{link_to pull.user.uname, user_path(pull.user)}" if pull.persisted? str.html_safe end diff --git a/app/models/ability.rb b/app/models/ability.rb index 0c01ad983..1ffd45c91 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -17,7 +17,7 @@ class Ability can :get_id, Project, :visibility => 'open' # api can :archive, Project, :visibility => 'open' can :read, Issue, :project => {:visibility => 'open'} - can :read, PullRequest, :base_project => {:visibility => 'open'} + can :read, PullRequest, :to_project => {:visibility => 'open'} can :search, BuildList can [:read, :log, :everything], BuildList, :project => {:visibility => 'open'} can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work @@ -124,11 +124,11 @@ class Ability can(:update, Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)} cannot :manage, Issue, :project => {:has_issues => false} # switch off issues - can :read, PullRequest, :base_project => {:owner_type => 'User', :owner_id => user.id} - can :read, PullRequest, :base_project => {:owner_type => 'Group', :owner_id => user.group_ids} - can(:read, PullRequest, read_relations_for('pull_requests', 'base_projects')) {|pull| can? :read, pull.base_project rescue nil} + can :read, PullRequest, :to_project => {:owner_type => 'User', :owner_id => user.id} + can :read, PullRequest, :to_project => {:owner_type => 'Group', :owner_id => user.group_ids} + can(:read, PullRequest, read_relations_for('pull_requests', 'to_projects')) {|pull| can? :read, pull.to_project rescue nil} can :create, PullRequest - can([:update, :merge], PullRequest) {|pull| pull.user_id == user.id or local_admin?(pull.base_project)} + can([:update, :merge], PullRequest) {|pull| pull.user_id == user.id or local_admin?(pull.to_project)} can(:create, Comment) {|comment| can? :read, comment.project} can(:update, Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)} diff --git a/app/models/project.rb b/app/models/project.rb index 81f9080e8..1c8bc74a9 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -8,7 +8,7 @@ class Project < ActiveRecord::Base belongs_to :maintainer, :class_name => "User" has_many :issues, :dependent => :destroy - has_many :pull_requests, :dependent => :destroy, :foreign_key => 'base_project_id' + has_many :pull_requests, :dependent => :destroy, :foreign_key => 'to_project_id' has_many :labels, :dependent => :destroy has_many :build_lists, :dependent => :destroy diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index f162edefa..2cdef2dfe 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -1,13 +1,13 @@ class PullRequest < ActiveRecord::Base STATUSES = %w(ready already blocked merged closed) belongs_to :issue, :autosave => true, :dependent => :destroy, :touch => true, :validate => true - belongs_to :base_project, :class_name => 'Project', :foreign_key => 'base_project_id' - belongs_to :head_project, :class_name => 'Project', :foreign_key => 'head_project_id' + belongs_to :to_project, :class_name => 'Project', :foreign_key => 'to_project_id' + belongs_to :from_project, :class_name => 'Project', :foreign_key => 'from_project_id' delegate :user, :user_id, :title, :body, :serial_id, :assignee, :status, :to_param, :created_at, :updated_at, :comments, :status=, :to => :issue, :allow_nil => true validate :uniq_merge - validates_each :head_ref, :base_ref do |record, attr, value| + validates_each :from_ref, :to_ref do |record, attr, value| check_ref record, attr, value end @@ -15,7 +15,7 @@ class PullRequest < ActiveRecord::Base after_destroy :clean_dir accepts_nested_attributes_for :issue - attr_accessible :issue_attributes, :base_ref, :head_ref + attr_accessible :issue_attributes, :to_ref, :from_ref scope :needed_checking, includes(:issue).where(:issues => {:status => ['open', 'blocked', 'ready']}) @@ -89,22 +89,22 @@ class PullRequest < ActiveRecord::Base end def path - filename = [id, head_project.owner.uname, head_project.name].compact.join('-') - File.join(APP_CONFIG['root_path'], 'pull_requests', base_project.owner.uname, base_project.name, filename) + filename = [id, from_project.owner.uname, from_project.name].compact.join('-') + File.join(APP_CONFIG['root_path'], 'pull_requests', to_project.owner.uname, to_project.name, filename) end def head_branch - if base_project != head_project - "head_#{head_ref}" + if to_project != from_project + "head_#{from_ref}" else - head_ref + from_ref end end def common_ancestor return @common_ancestor if @common_ancestor repo = Grit::Repo.new(path) - base_commit = repo.commits(base_ref).first + base_commit = repo.commits(to_ref).first head_commit = repo.commits(head_branch).first @common_ancestor = repo.commit(repo.git.merge_base({}, base_commit, head_commit)) || base_commit end @@ -144,13 +144,13 @@ class PullRequest < ActiveRecord::Base end def self.check_ref(record, attr, value) - project = attr == :head_ref ? record.head_project : record.base_project + project = attr == :from_ref ? record.from_project : record.to_project record.errors.add attr, I18n.t('projects.pull_requests.wrong_ref') unless project.repo.branches_and_tags.map(&:name).include?(value) end def uniq_merge - if base_project.pull_requests.needed_checking.where(:head_project_id => head_project, :base_ref => base_ref, :head_ref => head_ref).where('pull_requests.id <> :id or :id is null', :id => id).count > 0 - errors.add(:base_branch, I18n.t('projects.pull_requests.duplicate', :head_ref => head_ref)) + if to_project.pull_requests.needed_checking.where(:from_project_id => from_project, :to_ref => to_ref, :from_ref => from_ref).where('pull_requests.id <> :id or :id is null', :id => id).count > 0 + errors.add(:base_branch, I18n.t('projects.pull_requests.duplicate', :from_ref => from_ref)) end end @@ -158,34 +158,34 @@ class PullRequest < ActiveRecord::Base def merge clone - message = "Merge pull request ##{serial_id} from #{head_project.name_with_owner}:#{head_ref}\r\n #{title}" - %x(cd #{path} && git checkout #{base_ref} && git merge --no-ff #{head_branch} -m '#{message}') + message = "Merge pull request ##{serial_id} from #{from_project.name_with_owner}:#{from_ref}\r\n #{title}" + %x(cd #{path} && git checkout #{to_ref} && git merge --no-ff #{head_branch} -m '#{message}') end def clone git = Grit::Git.new(path) unless git.exist? #~ FileUtils.mkdir_p(path) - #~ system("git clone --local --no-hardlinks #{base_project.path} #{path}") - options = {:bare => false, :shared => false, :branch => base_ref} # shared? + #~ system("git clone --local --no-hardlinks #{to_project.path} #{path}") + options = {:bare => false, :shared => false, :branch => to_ref} # shared? git.fs_mkdir('..') - git.clone(options, base_project.path, path) - if base_project != head_project + git.clone(options, to_project.path, path) + if to_project != from_project Dir.chdir(path) do - system 'git', 'remote', 'add', 'head', head_project.path + system 'git', 'remote', 'add', 'head', from_project.path end end clean end Dir.chdir(path) do - system 'git', 'checkout', base_ref - system 'git', 'pull', 'origin', base_ref - if base_project == head_project - system 'git', 'checkout', head_ref - system 'git', 'pull', 'origin', head_ref + system 'git', 'checkout', to_ref + system 'git', 'pull', 'origin', to_ref + if to_project == from_project + system 'git', 'checkout', from_ref + system 'git', 'pull', 'origin', from_ref else - system 'git', 'fetch', 'head', "+#{head_ref}:#{head_branch}" + system 'git', 'fetch', 'head', "+#{from_ref}:#{head_branch}" end end # TODO catch errors @@ -193,14 +193,14 @@ class PullRequest < ActiveRecord::Base def clean Dir.chdir(path) do - base_project.repo.branches.each {|branch| system 'git', 'checkout', branch.name} - system 'git', 'checkout', base_ref + to_project.repo.branches.each {|branch| system 'git', 'checkout', branch.name} + system 'git', 'checkout', to_ref - base_project.repo.branches.each do |branch| - system 'git', 'branch', '-D', branch.name unless [base_ref, head_branch].include? branch.name + to_project.repo.branches.each do |branch| + system 'git', 'branch', '-D', branch.name unless [to_ref, head_branch].include? branch.name end - base_project.repo.tags.each do |tag| - system 'git', 'tag', '-d', tag.name unless [base_ref, head_branch].include? tag.name + to_project.repo.tags.each do |tag| + system 'git', 'tag', '-d', tag.name unless [to_ref, head_branch].include? tag.name end end end diff --git a/app/views/projects/projects/refs_list.html.haml b/app/views/projects/projects/refs_list.html.haml index 87bea0e21..43ea5f649 100644 --- a/app/views/projects/projects/refs_list.html.haml +++ b/app/views/projects/projects/refs_list.html.haml @@ -1 +1 @@ -=render 'projects/pull_requests/ref_select', :kind => 'base', :project => @project, :current => @selected +=render 'projects/pull_requests/ref_select', :kind => 'to', :project => @project, :current => @selected diff --git a/app/views/projects/pull_requests/new.html.haml b/app/views/projects/pull_requests/new.html.haml index 66dc87978..6ad43d4de 100644 --- a/app/views/projects/pull_requests/new.html.haml +++ b/app/views/projects/pull_requests/new.html.haml @@ -9,15 +9,15 @@ =hidden_field_tag :update_action, new_project_pull_request_path =form_for @pull, :url => (@pull.already? ? new_project_pull_request_path : project_pull_requests_path), :html => {:class => 'well well-large', :method => (@pull.already? ? :get : :post)} do |f| - .leftlist=f.label :head_project, t("#{ar}.head_project"), :class => :label + .leftlist=f.label :from_project, t("#{ar}.from_project"), :class => :label %div - .l=text_field_tag :head_project, @pull.head_project.name_with_owner, :readonly => :readonly, :style => 'background-color: #DDD;' - =render 'ref_select', :kind => 'head', :project => @pull.head_project, :current => @pull.head_ref + .l=text_field_tag :from_project, @pull.from_project.name_with_owner, :readonly => :readonly, :style => 'background-color: #DDD;' + =render 'ref_select', :kind => 'from', :project => @pull.from_project, :current => @pull.from_ref .both - .leftlist=f.label :base_project, t("#{ar}.base_project"), :class => :label + .leftlist=f.label :to_project, t("#{ar}.to_project"), :class => :label %div - .l=f.autocomplete_field :base_project, autocomplete_base_project_project_pull_requests_path, :value => @pull.base_project.name_with_owner, :id_element => 'pull_request_base_project_id', :name => 'base_project' - =render 'ref_select', :kind => 'base', :project => @pull.base_project, :current => @pull.base_ref + .l=f.autocomplete_field :to_project, autocomplete_to_project_project_pull_requests_path, :value => @pull.to_project.name_with_owner, :id_element => 'pull_request_to_project_id', :name => 'to_project' + =render 'ref_select', :kind => 'to', :project => @pull.to_project, :current => @pull.to_ref .both .leftlist.big-list .rightlist=f.submit t('.update'), :class => 'btn btn-primary disabled', 'data-loading-text' => t('layout.processing'), :style => @pull.already? ? '' : 'display: none;', :id => 'update_pull' diff --git a/config/locales/models/pull_request.en.yml b/config/locales/models/pull_request.en.yml index c8bfe70d0..268e4bcbc 100644 --- a/config/locales/models/pull_request.en.yml +++ b/config/locales/models/pull_request.en.yml @@ -12,14 +12,14 @@ en: close: Close Pull Request reopen: Reopen Pull Request merge: Merge - 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}' + duplicate: 'There is already a pull request for %{from_ref}' + up_to_date: 'The %{to_ref} branch is already up-to-date with %{from_ref}' wrong_ref: Wrong branch or tag blocked: 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} + %{user} merged into %{to_ref} + from %{from_ref} at %{time} closed: '%{user} closed this pull request at %{time}' is_big: This pull request is big! We're only showing the most recent %{count} commits. open: '' @@ -44,11 +44,11 @@ en: activerecord: attributes: pull_requests: - base_ref: Base - head_ref: Head + to_ref: Source + from_ref: Receiver refs: 'branch · tag' - base_project: Into - head_project: From + to_project: Into + from_project: From layout: pull_requests: diff --git a/config/locales/models/pull_request.ru.yml b/config/locales/models/pull_request.ru.yml index 93eb5cb2d..7ff23c518 100644 --- a/config/locales/models/pull_request.ru.yml +++ b/config/locales/models/pull_request.ru.yml @@ -14,14 +14,14 @@ ru: close: Закрыть пул реквест reopen: Переоткрыть пул реквест merge: Мерж - duplicate: 'Уже существует пул реквест %{head_ref}' - up_to_date: 'Ветка %{base_ref} на данный момент уже содержит последние изменения %{head_ref}' + duplicate: 'Уже существует пул реквест %{from_ref}' + up_to_date: 'Ветка %{to_ref} на данный момент уже содержит последние изменения %{from_ref}' wrong_ref: Неправильная ветка или тег blocked: Невозможно автоматически смержить данный пул реквест. ready: Данный пул реквест можно смержить автоматически. merged: | - %{user} смержил %{base_ref} - с %{head_ref} в %{time}' + %{user} смержил %{to_ref} + с %{from_ref} в %{time}' closed: '%{user} закрыл пул реквест в %{time}' is_big: Этот пул реквест слишком большой! Мы показываем только последние %{count} комитов. open: '' @@ -46,11 +46,11 @@ ru: activerecord: attributes: pull_requests: - base_ref: База - head_ref: Источник + to_ref: Приемник + from_ref: Источник refs: 'ветка · тег' - base_project: Куда - head_project: Откуда + to_project: Куда + from_project: Откуда layout: pull_requests: diff --git a/config/routes.rb b/config/routes.rb index 0f209bd47..ef1fd01a2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -206,7 +206,7 @@ Rosa::Application.routes.draw do get :find, :on => :collection end resources :pull_requests, :except => :destroy do - get :autocomplete_base_project, :on => :collection + get :autocomplete_to_project, :on => :collection put :merge, :on => :member end post '/preview' => 'projects#preview', :as => 'md_preview' diff --git a/db/migrate/20121003081546_rename_base_head_in_pull_requests.rb b/db/migrate/20121003081546_rename_base_head_in_pull_requests.rb new file mode 100644 index 000000000..4e12b9696 --- /dev/null +++ b/db/migrate/20121003081546_rename_base_head_in_pull_requests.rb @@ -0,0 +1,10 @@ +class RenameBaseHeadInPullRequests < ActiveRecord::Migration + def change + change_table :pull_requests do |t| + t.rename :base_project_id, :to_project_id + t.rename :base_ref, :to_ref + t.rename :head_project_id, :from_project_id + t.rename :head_ref, :from_ref + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4a941ab09..3886a06af 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120914160741) do +ActiveRecord::Schema.define(:version => 20121003081546) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -343,15 +343,15 @@ ActiveRecord::Schema.define(:version => 20120914160741) do create_table "pull_requests", :force => true do |t| t.integer "issue_id", :null => false - t.integer "base_project_id", :null => false - t.integer "head_project_id", :null => false - t.string "base_ref", :null => false - t.string "head_ref", :null => false + t.integer "to_project_id", :null => false + t.integer "from_project_id", :null => false + t.string "to_ref", :null => false + t.string "from_ref", :null => false end - add_index "pull_requests", ["base_project_id"], :name => "index_pull_requests_on_base_project_id" - add_index "pull_requests", ["head_project_id"], :name => "index_pull_requests_on_head_project_id" + add_index "pull_requests", ["from_project_id"], :name => "index_pull_requests_on_head_project_id" add_index "pull_requests", ["issue_id"], :name => "index_pull_requests_on_issue_id" + add_index "pull_requests", ["to_project_id"], :name => "index_pull_requests_on_base_project_id" create_table "register_requests", :force => true do |t| t.string "name"