[refs #90] base -> to, head -> from
This commit is contained in:
parent
1d424b463c
commit
94029c3cda
|
@ -2,12 +2,12 @@ $(document).ready(function() {
|
||||||
var upd_action = $('#update_action').val();
|
var upd_action = $('#update_action').val();
|
||||||
var form = $('#new_pull_request');
|
var form = $('#new_pull_request');
|
||||||
|
|
||||||
$('#pull_request_base_project').on('autocompleteselect', function(event, data){
|
$('#pull_request_to_project').on('autocompleteselect', function(event, data){
|
||||||
var ref = $('#base_ref');
|
var ref = $('#to_ref');
|
||||||
ref.parent().load(data.item.get_refs_url+' #base_ref', {"selected": ref.val()});
|
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)
|
form.attr('action', upd_action)
|
||||||
.attr('method', 'get');
|
.attr('method', 'get');
|
||||||
$('#update_pull').fadeIn('fast');
|
$('#update_pull').fadeIn('fast');
|
||||||
|
|
|
@ -1571,8 +1571,6 @@ table.tablesorter.platform-maintainers.static-search thead tr.search th input[ty
|
||||||
.edit_comment .comment-left {
|
.edit_comment .comment-left {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#open-comment > h3.tmargin0 {
|
#open-comment > h3.tmargin0 {
|
||||||
|
|
|
@ -4,24 +4,24 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
||||||
load_and_authorize_resource :project
|
load_and_authorize_resource :project
|
||||||
|
|
||||||
load_resource :issue, :through => :project, :find_by => :serial_id, :parent => false, :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_base_project]
|
load_and_authorize_resource :instance_name => :pull, :through => :issue, :singleton => true, :except => [:index, :autocomplete_to_project]
|
||||||
|
|
||||||
def new
|
def new
|
||||||
base_project = set_base_project(false)
|
to_project = set_to_project(false)
|
||||||
authorize! :read, base_project
|
authorize! :read, to_project
|
||||||
|
|
||||||
@pull = base_project.pull_requests.new
|
@pull = to_project.pull_requests.new
|
||||||
@pull.issue = base_project.issues.new
|
@pull.issue = to_project.issues.new
|
||||||
set_attrs
|
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('. ')
|
flash.now[:warning] = @pull.errors.full_messages.join('. ')
|
||||||
else
|
else
|
||||||
@pull.check(false) # don't make event transaction
|
@pull.check(false) # don't make event transaction
|
||||||
if @pull.already?
|
if @pull.already?
|
||||||
@pull.destroy
|
@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
|
else
|
||||||
load_diff_commits_data
|
load_diff_commits_data
|
||||||
end
|
end
|
||||||
|
@ -33,28 +33,28 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
raise 'expect pull_request params' # for debug
|
raise 'expect pull_request params' # for debug
|
||||||
redirect :back
|
redirect :back
|
||||||
end
|
end
|
||||||
base_project = set_base_project
|
to_project = set_to_project
|
||||||
authorize! :read, base_project
|
authorize! :read, to_project
|
||||||
|
|
||||||
@pull = base_project.pull_requests.new pull_params
|
@pull = to_project.pull_requests.new pull_params
|
||||||
@pull.issue.user, @pull.issue.project, @pull.head_project = current_user, base_project, @project
|
@pull.issue.user, @pull.issue.project, @pull.from_project = current_user, to_project, @project
|
||||||
|
|
||||||
if @pull.valid? # FIXME more clean/clever logics
|
if @pull.valid? # FIXME more clean/clever logics
|
||||||
@pull.save # set pull id
|
@pull.save # set pull id
|
||||||
@pull.check(false) # don't make event transaction
|
@pull.check(false) # don't make event transaction
|
||||||
if @pull.already?
|
if @pull.already?
|
||||||
@pull.destroy
|
@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
|
render :new
|
||||||
else
|
else
|
||||||
@pull.send(@pull.status)
|
@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
|
end
|
||||||
else
|
else
|
||||||
flash.now[:error] = t('flash.pull_request.save_error')
|
flash.now[:error] = t('flash.pull_request.save_error')
|
||||||
flash.now[:warning] = @pull.errors.full_messages.join('. ')
|
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
|
@pull.check(false) # don't make event transaction
|
||||||
load_diff_commits_data
|
load_diff_commits_data
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
@pull.check if @pull.open?
|
@pull.check if @pull.open?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to project_pull_request_path(@pull.base_project, @pull)
|
redirect_to project_pull_request_path(@pull.to_project, @pull)
|
||||||
end
|
end
|
||||||
|
|
||||||
def merge
|
def merge
|
||||||
|
@ -79,7 +79,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
flash.now[:error] = t('flash.pull_request.save_error')
|
flash.now[:error] = t('flash.pull_request.save_error')
|
||||||
flash.now[:warning] = @pull.errors.full_messages.join('. ')
|
flash.now[:warning] = @pull.errors.full_messages.join('. ')
|
||||||
end
|
end
|
||||||
redirect_to project_pull_request_path(@pull.base_project, @pull)
|
redirect_to project_pull_request_path(@pull.to_project, @pull)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -107,7 +107,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def autocomplete_base_project
|
def autocomplete_to_project
|
||||||
items = Project.accessible_by(current_ability, :membered) | @project.ancestors
|
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}
|
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)
|
render :json => json_for_autocomplete_base(items)
|
||||||
|
@ -132,7 +132,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
@base_commit = @pull.common_ancestor
|
@base_commit = @pull.common_ancestor
|
||||||
@head_commit = repo.commits(@pull.head_branch).first
|
@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
|
@total_commits = @commits.count
|
||||||
@commits = @commits.last(100)
|
@commits = @commits.last(100)
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
@stats = @pull.diff_stats repo, @base_commit, @head_commit
|
@stats = @pull.diff_stats repo, @base_commit, @head_commit
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_base_project bang=true
|
def set_to_project bang=true
|
||||||
args = params[:base_project].try(:split, '/') || []
|
args = params[:to_project].try(:split, '/') || []
|
||||||
if bang
|
if bang
|
||||||
raise ActiveRecord::RecordNotFound if args.length != 2
|
raise ActiveRecord::RecordNotFound if args.length != 2
|
||||||
Project.find_by_owner_and_name! *args
|
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.title = pull_params[:issue_attributes][:title].presence
|
||||||
@pull.issue.body = pull_params[:issue_attributes][:body].presence
|
@pull.issue.body = pull_params[:issue_attributes][:body].presence
|
||||||
end
|
end
|
||||||
@pull.head_project = @project
|
@pull.from_project = @project
|
||||||
@pull.base_ref = (pull_params[:base_ref].presence if pull_params) || @pull.base_project.default_branch
|
@pull.to_ref = (pull_params[:to_ref].presence if pull_params) || @pull.to_project.default_branch
|
||||||
@pull.head_ref = params[:treeish].presence || (pull_params[:head_ref].presence if pull_params) || @pull.head_project.default_branch
|
@pull.from_ref = params[:treeish].presence || (pull_params[:from_ref].presence if pull_params) || @pull.from_project.default_branch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,8 +13,8 @@ module PullRequestHelper
|
||||||
|
|
||||||
def pull_status pull
|
def pull_status pull
|
||||||
if %w(blocked merged closed ready open).include? pull.status
|
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'),
|
t("projects.pull_requests.#{pull.status}", :user => pull.issue.closer.try(:uname), :to_ref => show_ref(pull, 'to'),
|
||||||
:head_ref => show_ref(pull, 'head'), :time => pull.issue.closed_at).html_safe
|
:from_ref => show_ref(pull, 'from'), :time => pull.issue.closed_at).html_safe
|
||||||
else
|
else
|
||||||
raise "pull id (#{pull.id}) wrong status #{pull.status} "
|
raise "pull id (#{pull.id}) wrong status #{pull.status} "
|
||||||
end
|
end
|
||||||
|
@ -22,9 +22,9 @@ module PullRequestHelper
|
||||||
|
|
||||||
def pull_header pull
|
def pull_header pull
|
||||||
str = "#{t '.header'} #{t 'from'} <span class='label-bootstrap label-info font14'> \
|
str = "#{t '.header'} #{t 'from'} <span class='label-bootstrap label-info font14'> \
|
||||||
#{show_ref pull, 'head'}</span> \
|
#{show_ref pull, 'from'}</span> \
|
||||||
#{t 'into'} <span class='label-bootstrap label-info font14'> \
|
#{t 'into'} <span class='label-bootstrap label-info font14'> \
|
||||||
#{show_ref pull, 'base'}</span>"
|
#{show_ref pull, 'to'}</span>"
|
||||||
str << " #{t 'by'} #{link_to pull.user.uname, user_path(pull.user)}" if pull.persisted?
|
str << " #{t 'by'} #{link_to pull.user.uname, user_path(pull.user)}" if pull.persisted?
|
||||||
str.html_safe
|
str.html_safe
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Ability
|
||||||
can :get_id, Project, :visibility => 'open' # api
|
can :get_id, Project, :visibility => 'open' # api
|
||||||
can :archive, Project, :visibility => 'open'
|
can :archive, Project, :visibility => 'open'
|
||||||
can :read, Issue, :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 :search, BuildList
|
||||||
can [:read, :log, :everything], BuildList, :project => {:visibility => 'open'}
|
can [:read, :log, :everything], BuildList, :project => {:visibility => 'open'}
|
||||||
can :read, ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work
|
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)}
|
can(:update, Issue) {|issue| issue.user_id == user.id or local_admin?(issue.project)}
|
||||||
cannot :manage, Issue, :project => {:has_issues => false} # switch off issues
|
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, :to_project => {:owner_type => 'User', :owner_id => user.id}
|
||||||
can :read, PullRequest, :base_project => {:owner_type => 'Group', :owner_id => user.group_ids}
|
can :read, PullRequest, :to_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, read_relations_for('pull_requests', 'to_projects')) {|pull| can? :read, pull.to_project rescue nil}
|
||||||
can :create, PullRequest
|
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(:create, Comment) {|comment| can? :read, comment.project}
|
||||||
can(:update, Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
|
can(:update, Comment) {|comment| comment.user == user or comment.project.owner == user or local_admin?(comment.project)}
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Project < ActiveRecord::Base
|
||||||
belongs_to :maintainer, :class_name => "User"
|
belongs_to :maintainer, :class_name => "User"
|
||||||
|
|
||||||
has_many :issues, :dependent => :destroy
|
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 :labels, :dependent => :destroy
|
||||||
has_many :build_lists, :dependent => :destroy
|
has_many :build_lists, :dependent => :destroy
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
class PullRequest < ActiveRecord::Base
|
class PullRequest < ActiveRecord::Base
|
||||||
STATUSES = %w(ready already blocked merged closed)
|
STATUSES = %w(ready already blocked merged closed)
|
||||||
belongs_to :issue, :autosave => true, :dependent => :destroy, :touch => true, :validate => true
|
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 :to_project, :class_name => 'Project', :foreign_key => 'to_project_id'
|
||||||
belongs_to :head_project, :class_name => 'Project', :foreign_key => 'head_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,
|
delegate :user, :user_id, :title, :body, :serial_id, :assignee, :status, :to_param,
|
||||||
:created_at, :updated_at, :comments, :status=, :to => :issue, :allow_nil => true
|
:created_at, :updated_at, :comments, :status=, :to => :issue, :allow_nil => true
|
||||||
|
|
||||||
validate :uniq_merge
|
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
|
check_ref record, attr, value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class PullRequest < ActiveRecord::Base
|
||||||
after_destroy :clean_dir
|
after_destroy :clean_dir
|
||||||
|
|
||||||
accepts_nested_attributes_for :issue
|
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']})
|
scope :needed_checking, includes(:issue).where(:issues => {:status => ['open', 'blocked', 'ready']})
|
||||||
|
|
||||||
|
@ -89,22 +89,22 @@ class PullRequest < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def path
|
def path
|
||||||
filename = [id, head_project.owner.uname, head_project.name].compact.join('-')
|
filename = [id, from_project.owner.uname, from_project.name].compact.join('-')
|
||||||
File.join(APP_CONFIG['root_path'], 'pull_requests', base_project.owner.uname, base_project.name, filename)
|
File.join(APP_CONFIG['root_path'], 'pull_requests', to_project.owner.uname, to_project.name, filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
def head_branch
|
def head_branch
|
||||||
if base_project != head_project
|
if to_project != from_project
|
||||||
"head_#{head_ref}"
|
"head_#{from_ref}"
|
||||||
else
|
else
|
||||||
head_ref
|
from_ref
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def common_ancestor
|
def common_ancestor
|
||||||
return @common_ancestor if @common_ancestor
|
return @common_ancestor if @common_ancestor
|
||||||
repo = Grit::Repo.new(path)
|
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
|
head_commit = repo.commits(head_branch).first
|
||||||
@common_ancestor = repo.commit(repo.git.merge_base({}, base_commit, head_commit)) || base_commit
|
@common_ancestor = repo.commit(repo.git.merge_base({}, base_commit, head_commit)) || base_commit
|
||||||
end
|
end
|
||||||
|
@ -144,13 +144,13 @@ class PullRequest < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.check_ref(record, attr, value)
|
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)
|
record.errors.add attr, I18n.t('projects.pull_requests.wrong_ref') unless project.repo.branches_and_tags.map(&:name).include?(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def uniq_merge
|
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
|
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', :head_ref => head_ref))
|
errors.add(:base_branch, I18n.t('projects.pull_requests.duplicate', :from_ref => from_ref))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -158,34 +158,34 @@ class PullRequest < ActiveRecord::Base
|
||||||
|
|
||||||
def merge
|
def merge
|
||||||
clone
|
clone
|
||||||
message = "Merge pull request ##{serial_id} from #{head_project.name_with_owner}:#{head_ref}\r\n #{title}"
|
message = "Merge pull request ##{serial_id} from #{from_project.name_with_owner}:#{from_ref}\r\n #{title}"
|
||||||
%x(cd #{path} && git checkout #{base_ref} && git merge --no-ff #{head_branch} -m '#{message}')
|
%x(cd #{path} && git checkout #{to_ref} && git merge --no-ff #{head_branch} -m '#{message}')
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone
|
def clone
|
||||||
git = Grit::Git.new(path)
|
git = Grit::Git.new(path)
|
||||||
unless git.exist?
|
unless git.exist?
|
||||||
#~ FileUtils.mkdir_p(path)
|
#~ FileUtils.mkdir_p(path)
|
||||||
#~ system("git clone --local --no-hardlinks #{base_project.path} #{path}")
|
#~ system("git clone --local --no-hardlinks #{to_project.path} #{path}")
|
||||||
options = {:bare => false, :shared => false, :branch => base_ref} # shared?
|
options = {:bare => false, :shared => false, :branch => to_ref} # shared?
|
||||||
git.fs_mkdir('..')
|
git.fs_mkdir('..')
|
||||||
git.clone(options, base_project.path, path)
|
git.clone(options, to_project.path, path)
|
||||||
if base_project != head_project
|
if to_project != from_project
|
||||||
Dir.chdir(path) do
|
Dir.chdir(path) do
|
||||||
system 'git', 'remote', 'add', 'head', head_project.path
|
system 'git', 'remote', 'add', 'head', from_project.path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
clean
|
clean
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.chdir(path) do
|
Dir.chdir(path) do
|
||||||
system 'git', 'checkout', base_ref
|
system 'git', 'checkout', to_ref
|
||||||
system 'git', 'pull', 'origin', base_ref
|
system 'git', 'pull', 'origin', to_ref
|
||||||
if base_project == head_project
|
if to_project == from_project
|
||||||
system 'git', 'checkout', head_ref
|
system 'git', 'checkout', from_ref
|
||||||
system 'git', 'pull', 'origin', head_ref
|
system 'git', 'pull', 'origin', from_ref
|
||||||
else
|
else
|
||||||
system 'git', 'fetch', 'head', "+#{head_ref}:#{head_branch}"
|
system 'git', 'fetch', 'head', "+#{from_ref}:#{head_branch}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# TODO catch errors
|
# TODO catch errors
|
||||||
|
@ -193,14 +193,14 @@ class PullRequest < ActiveRecord::Base
|
||||||
|
|
||||||
def clean
|
def clean
|
||||||
Dir.chdir(path) do
|
Dir.chdir(path) do
|
||||||
base_project.repo.branches.each {|branch| system 'git', 'checkout', branch.name}
|
to_project.repo.branches.each {|branch| system 'git', 'checkout', branch.name}
|
||||||
system 'git', 'checkout', base_ref
|
system 'git', 'checkout', to_ref
|
||||||
|
|
||||||
base_project.repo.branches.each do |branch|
|
to_project.repo.branches.each do |branch|
|
||||||
system 'git', 'branch', '-D', branch.name unless [base_ref, head_branch].include? branch.name
|
system 'git', 'branch', '-D', branch.name unless [to_ref, head_branch].include? branch.name
|
||||||
end
|
end
|
||||||
base_project.repo.tags.each do |tag|
|
to_project.repo.tags.each do |tag|
|
||||||
system 'git', 'tag', '-d', tag.name unless [base_ref, head_branch].include? tag.name
|
system 'git', 'tag', '-d', tag.name unless [to_ref, head_branch].include? tag.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -9,15 +9,15 @@
|
||||||
=hidden_field_tag :update_action, new_project_pull_request_path
|
=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|
|
=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
|
%div
|
||||||
.l=text_field_tag :head_project, @pull.head_project.name_with_owner, :readonly => :readonly, :style => 'background-color: #DDD;'
|
.l=text_field_tag :from_project, @pull.from_project.name_with_owner, :readonly => :readonly, :style => 'background-color: #DDD;'
|
||||||
=render 'ref_select', :kind => 'head', :project => @pull.head_project, :current => @pull.head_ref
|
=render 'ref_select', :kind => 'from', :project => @pull.from_project, :current => @pull.from_ref
|
||||||
.both
|
.both
|
||||||
.leftlist=f.label :base_project, t("#{ar}.base_project"), :class => :label
|
.leftlist=f.label :to_project, t("#{ar}.to_project"), :class => :label
|
||||||
%div
|
%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'
|
.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 => 'base', :project => @pull.base_project, :current => @pull.base_ref
|
=render 'ref_select', :kind => 'to', :project => @pull.to_project, :current => @pull.to_ref
|
||||||
.both
|
.both
|
||||||
.leftlist.big-list
|
.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'
|
.rightlist=f.submit t('.update'), :class => 'btn btn-primary disabled', 'data-loading-text' => t('layout.processing'), :style => @pull.already? ? '' : 'display: none;', :id => 'update_pull'
|
||||||
|
|
|
@ -12,14 +12,14 @@ en:
|
||||||
close: Close Pull Request
|
close: Close Pull Request
|
||||||
reopen: Reopen Pull Request
|
reopen: Reopen Pull Request
|
||||||
merge: Merge
|
merge: Merge
|
||||||
duplicate: 'There is already a pull request for %{head_ref}'
|
duplicate: 'There is already a pull request for %{from_ref}'
|
||||||
up_to_date: 'The %{base_ref} branch is already up-to-date with %{head_ref}'
|
up_to_date: 'The %{to_ref} branch is already up-to-date with %{from_ref}'
|
||||||
wrong_ref: Wrong branch or tag
|
wrong_ref: Wrong branch or tag
|
||||||
blocked: This pull request cannot be automatically merged.
|
blocked: This pull request cannot be automatically merged.
|
||||||
ready: This pull request can be automatically merged.
|
ready: This pull request can be automatically merged.
|
||||||
merged: |
|
merged: |
|
||||||
%{user} merged into <span class="label-bootstrap label-info font14">%{base_ref}</span>
|
%{user} merged into <span class="label-bootstrap label-info font14">%{to_ref}</span>
|
||||||
from <span class="label-bootstrap label-info font14">%{head_ref}</span> at %{time}
|
from <span class="label-bootstrap label-info font14">%{from_ref}</span> at %{time}
|
||||||
closed: '%{user} closed this pull request 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.
|
is_big: This pull request is big! We're only showing the most recent %{count} commits.
|
||||||
open: ''
|
open: ''
|
||||||
|
@ -44,11 +44,11 @@ en:
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
pull_requests:
|
pull_requests:
|
||||||
base_ref: Base
|
to_ref: Source
|
||||||
head_ref: Head
|
from_ref: Receiver
|
||||||
refs: 'branch · tag'
|
refs: 'branch · tag'
|
||||||
base_project: Into
|
to_project: Into
|
||||||
head_project: From
|
from_project: From
|
||||||
|
|
||||||
layout:
|
layout:
|
||||||
pull_requests:
|
pull_requests:
|
||||||
|
|
|
@ -14,14 +14,14 @@ ru:
|
||||||
close: Закрыть пул реквест
|
close: Закрыть пул реквест
|
||||||
reopen: Переоткрыть пул реквест
|
reopen: Переоткрыть пул реквест
|
||||||
merge: Мерж
|
merge: Мерж
|
||||||
duplicate: 'Уже существует пул реквест %{head_ref}'
|
duplicate: 'Уже существует пул реквест %{from_ref}'
|
||||||
up_to_date: 'Ветка %{base_ref} на данный момент уже содержит последние изменения %{head_ref}'
|
up_to_date: 'Ветка %{to_ref} на данный момент уже содержит последние изменения %{from_ref}'
|
||||||
wrong_ref: Неправильная ветка или тег
|
wrong_ref: Неправильная ветка или тег
|
||||||
blocked: Невозможно автоматически смержить данный пул реквест.
|
blocked: Невозможно автоматически смержить данный пул реквест.
|
||||||
ready: Данный пул реквест можно смержить автоматически.
|
ready: Данный пул реквест можно смержить автоматически.
|
||||||
merged: |
|
merged: |
|
||||||
%{user} смержил <span class="label-bootstrap label-info font14">%{base_ref}</span>
|
%{user} смержил <span class="label-bootstrap label-info font14">%{to_ref}</span>
|
||||||
с <span class="label-bootstrap label-info font14">%{head_ref}</span> в %{time}'
|
с <span class="label-bootstrap label-info font14">%{from_ref}</span> в %{time}'
|
||||||
closed: '%{user} закрыл пул реквест в %{time}'
|
closed: '%{user} закрыл пул реквест в %{time}'
|
||||||
is_big: Этот пул реквест слишком большой! Мы показываем только последние %{count} комитов.
|
is_big: Этот пул реквест слишком большой! Мы показываем только последние %{count} комитов.
|
||||||
open: ''
|
open: ''
|
||||||
|
@ -46,11 +46,11 @@ ru:
|
||||||
activerecord:
|
activerecord:
|
||||||
attributes:
|
attributes:
|
||||||
pull_requests:
|
pull_requests:
|
||||||
base_ref: База
|
to_ref: Приемник
|
||||||
head_ref: Источник
|
from_ref: Источник
|
||||||
refs: 'ветка · тег'
|
refs: 'ветка · тег'
|
||||||
base_project: Куда
|
to_project: Куда
|
||||||
head_project: Откуда
|
from_project: Откуда
|
||||||
|
|
||||||
layout:
|
layout:
|
||||||
pull_requests:
|
pull_requests:
|
||||||
|
|
|
@ -206,7 +206,7 @@ Rosa::Application.routes.draw do
|
||||||
get :find, :on => :collection
|
get :find, :on => :collection
|
||||||
end
|
end
|
||||||
resources :pull_requests, :except => :destroy do
|
resources :pull_requests, :except => :destroy do
|
||||||
get :autocomplete_base_project, :on => :collection
|
get :autocomplete_to_project, :on => :collection
|
||||||
put :merge, :on => :member
|
put :merge, :on => :member
|
||||||
end
|
end
|
||||||
post '/preview' => 'projects#preview', :as => 'md_preview'
|
post '/preview' => 'projects#preview', :as => 'md_preview'
|
||||||
|
|
|
@ -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
|
14
db/schema.rb
14
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# 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|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
|
@ -343,15 +343,15 @@ ActiveRecord::Schema.define(:version => 20120914160741) do
|
||||||
|
|
||||||
create_table "pull_requests", :force => true do |t|
|
create_table "pull_requests", :force => true do |t|
|
||||||
t.integer "issue_id", :null => false
|
t.integer "issue_id", :null => false
|
||||||
t.integer "base_project_id", :null => false
|
t.integer "to_project_id", :null => false
|
||||||
t.integer "head_project_id", :null => false
|
t.integer "from_project_id", :null => false
|
||||||
t.string "base_ref", :null => false
|
t.string "to_ref", :null => false
|
||||||
t.string "head_ref", :null => false
|
t.string "from_ref", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "pull_requests", ["base_project_id"], :name => "index_pull_requests_on_base_project_id"
|
add_index "pull_requests", ["from_project_id"], :name => "index_pull_requests_on_head_project_id"
|
||||||
add_index "pull_requests", ["head_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", ["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|
|
create_table "register_requests", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
|
Loading…
Reference in New Issue