[refs #90] diff - dont work

This commit is contained in:
Alexander Machehin 2012-05-05 22:57:12 +06:00
parent 813afe53cf
commit 381ae0a8b9
4 changed files with 31 additions and 8 deletions

View File

@ -13,8 +13,14 @@ class Projects::PullRequestsController < Projects::BaseController
@pull.issue = @project.issues.new
@pull.head_project = @project
@base_ref = @pull.base_project.default_branch
@head_ref = params[:treeish].presence || @pull.head_project.default_branch
@pull.base_ref = @pull.base_project.default_branch
@pull.head_ref = params[:treeish].presence || @pull.head_project.default_branch
@base_commit = @pull.base_project.git_repository.commits(@base_ref).first
@head_commit = @pull.head_project.git_repository.commits(@head_ref).first
@pull.check
#@pull.save
@diff = Grit::Repo.new(@pull.path).diff @base_commit, @head_commit
end
def create

View File

@ -6,7 +6,7 @@ class PullRequest < ActiveRecord::Base
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'
delegate :user, :title, :body, :serial_id, :assignee, :to => :issue, :allow_nil => true
delegate :user, :title, :body, :serial_id, :assignee, :state, :to => :issue, :allow_nil => true
accepts_nested_attributes_for :issue
#attr_accessible #FIXME disable for development
@ -89,10 +89,8 @@ class PullRequest < ActiveRecord::Base
end
end
protected
def path
filename = [id, base_project.owner.uname, base_project.name].join('-')
filename = [base_project.owner.uname, base_project.name, base_ref, head_ref].join('-')
if Rails.env == "production"
File.join('/srv/rosa_build/shared/tmp', "pull_requests", filename)
else
@ -100,6 +98,8 @@ class PullRequest < ActiveRecord::Base
end
end
protected
def merge
clone
%x(cd #{path} && git checkout #{base_ref} && git merge --no-ff #{head_ref}) #FIXME need sanitize branch name!

View File

@ -0,0 +1,10 @@
- commit_id = commit_diff.deleted_file ? @head_commit.parents.first.id : @head_commit.id
.file
%a{:name => h(commit_diff.a_path)}
.top
.l= h(commit_diff.a_path)
-# if commit_diff.b_path.present?
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path)
.clear
.diff_data= render_diff(commit_diff) unless (Git::Repository.new(@pull.path).tree(commit_id) / commit_diff.b_path).binary?

View File

@ -31,8 +31,15 @@
\ 
.rightlist=f.submit t('.submit'), :class => 'btn btn-primary disabled', 'data-loading-text' => t('layout.processing'), :id => 'create_pull'
.both
#diff.tab-pane.active ...
#commits.tab-pane.active ...
#diff.tab-pane
=@head_commit
-begin
=# render_commit_stats(stats)
= render :partial => 'commit_diff', :collection => @diff
- rescue Grit::Git::GitTimeout
%p= t 'layout.git.repositories.commit_diff_too_big'
#commits.tab-pane ...
:javascript
$(function () {