Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/git/git-scm.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/doc.rb')
-rw-r--r--app/models/doc.rb26
1 files changed, 0 insertions, 26 deletions
diff --git a/app/models/doc.rb b/app/models/doc.rb
index 8d5d8ffa..16c07893 100644
--- a/app/models/doc.rb
+++ b/app/models/doc.rb
@@ -12,30 +12,4 @@ class Doc < ActiveRecord::Base
has_many :doc_versions
- # returns an array of the differences with 3 entries
- # 0: additions
- # 1: subtractions
- # 2: 8 - (add + sub)
- def self.get_diff(sha_to, sha_from)
- key = "diff-#{sha_to}-#{sha_from}"
- doc_to = Doc.where(:blob_sha => sha_to).first.plain.split("\n")
- doc_from = Doc.where(:blob_sha => sha_from).first.plain.split("\n")
- diff = Diff::LCS.diff(doc_to, doc_from)
- total = adds = mins = 0
- diff.first.each do |change|
- adds += 1 if change.action == '+'
- mins += 1 if change.action == '-'
- total += 1
- end
- if total > 8
- min = (8.0 / total)
- adds = (adds * min).floor
- mins = (mins * min).floor
- [adds, mins, (8 - total)]
- else
- [adds, mins, (8 - total)]
- end
- rescue
- [0, 0, 8]
- end
end