summaryrefslogtreecommitdiff
path: root/app/models/merge_request.rb
diff options
context:
space:
mode:
authorRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-11-23 00:55:57 +0100
committerRiyad Preukschas <riyad@informatik.uni-bremen.de>2012-11-25 00:05:47 +0100
commitb3834bc9b03566252ca83f70f4af882561ac261f (patch)
tree02bdf590bbfa73805b46709dbad2ca84dfac2658 /app/models/merge_request.rb
parent2b1afa0e62e275c7b4df71ad454af34d454e0e17 (diff)
downloadgitlab-ce-b3834bc9b03566252ca83f70f4af882561ac261f.tar.gz
Remove MergeRequest#to_raw and replace it with #to_diff and #to_patch
Diffstat (limited to 'app/models/merge_request.rb')
-rw-r--r--app/models/merge_request.rb26
1 files changed, 14 insertions, 12 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 0766e5baa72..8039813ad1c 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -202,20 +202,22 @@ class MergeRequest < ActiveRecord::Base
false
end
- def to_raw
- FileUtils.mkdir_p(Rails.root.join("tmp", "patches"))
- patch_path = Rails.root.join("tmp", "patches", "merge_request_#{self.id}.patch")
-
- from = commits.last.id
- to = source_branch
-
- project.repo.git.run('', "format-patch" , " > #{patch_path.to_s}", {}, ["#{from}..#{to}", "--stdout"])
-
- patch_path
- end
-
def mr_and_commit_notes
commit_ids = commits.map(&:id)
Note.where("(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND noteable_id IN (:commit_ids))", mr_id: id, commit_ids: commit_ids)
end
+
+ # Returns the raw diff for this merge request
+ #
+ # see "git diff"
+ def to_diff
+ project.repo.git.native(:diff, {timeout: 30, raise: true}, "#{target_branch}...#{source_branch}")
+ end
+
+ # Returns the commit as a series of email patches.
+ #
+ # see "git format-patch"
+ def to_patch
+ project.repo.git.format_patch({timeout: 30, raise: true, stdout: true}, "#{target_branch}..#{source_branch}")
+ end
end