From 96d49bf04ce77c975fe500f4d961e4a1ffed4c26 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 30 Dec 2012 14:43:00 +0200 Subject: Use sdoc to generate application code documentation --- doc/code/classes/Commit.html | 1077 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1077 insertions(+) create mode 100644 doc/code/classes/Commit.html (limited to 'doc/code/classes/Commit.html') diff --git a/doc/code/classes/Commit.html b/doc/code/classes/Commit.html new file mode 100644 index 00000000000..15369b8981a --- /dev/null +++ b/doc/code/classes/Commit.html @@ -0,0 +1,1077 @@ + + + + + Commit + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + +
Methods
+
+ +
A
+
+ +
+ +
C
+
+ +
+ +
D
+
+ +
+ +
F
+
+ +
+ +
N
+
+
    + + +
  • + new +
  • + +
+
+ +
P
+
+ +
+ +
S
+
+ +
+ +
T
+
+ +
+ +
+ + + + +
Included Modules
+ + + + + + + + + + + + + +
Constants
+ + + + + + + + + + + + + + +
DIFF_SAFE_SIZE=100
 

Safe amount of files with diffs in one commit to render Used to prevent 500 +error on huge commits by suppressing diff

+ + + + + +
Attributes
+ + + + + + + + + + + + + + + + + + + + +
+ [RW] + commit
+ [RW] + head
+ [RW] + refs
+ + + + + +
Class Public methods
+ +
+
+ + commits(repo, ref, path = nil, limit = nil, offset = nil) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 62
+def commits(repo, ref, path = nil, limit = nil, offset = nil)
+  if path
+    repo.log(ref, path, max_count: limit, skip: offset)
+  elsif limit && offset
+    repo.commits(ref, limit, offset)
+  else
+    repo.commits(ref)
+  end.map{ |c| Commit.new(c) }
+end
+
+
+ +
+ +
+
+ + commits_between(repo, from, to) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 72
+def commits_between(repo, from, to)
+  repo.commits_between(from, to).map { |c| Commit.new(c) }
+end
+
+
+ +
+ +
+
+ + commits_since(repo, date) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 50
+def commits_since(repo, date)
+  commits = repo.heads.map do |h|
+    repo.log(h.name, nil, since: date).each { |c| Commit.new(c, h) }
+  end.flatten.uniq { |c| c.id }
+
+  commits.sort! do |x, y|
+    y.committed_date <=> x.committed_date
+  end
+
+  commits
+end
+
+
+ +
+ +
+
+ + commits_with_refs(repo, n = 20) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 40
+def commits_with_refs(repo, n = 20)
+  commits = repo.branches.map { |ref| Commit.new(ref.commit, ref) }
+
+  commits.sort! do |x, y|
+    y.committed_date <=> x.committed_date
+  end
+
+  commits[0..n]
+end
+
+
+ +
+ +
+
+ + compare(project, from, to) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 76
+def compare(project, from, to)
+  result = {
+    commits: [],
+    diffs: [],
+    commit: nil,
+    same: false
+  }
+
+  return result unless from && to
+
+  first = project.commit(to.try(:strip))
+  last = project.commit(from.try(:strip))
+
+  if first && last
+    result[:same] = (first.id == last.id)
+    result[:commits] = project.repo.commits_between(last.id, first.id).map {|c| Commit.new(c)}
+    result[:diffs] = project.repo.diff(last.id, first.id) rescue []
+    result[:commit] = Commit.new(first)
+  end
+
+  result
+end
+
+
+ +
+ +
+
+ + find_or_first(repo, commit_id = nil, root_ref) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 18
+def find_or_first(repo, commit_id = nil, root_ref)
+  commit = if commit_id
+             repo.commit(commit_id)
+           else
+             repo.commits(root_ref).first
+           end
+
+  Commit.new(commit) if commit
+end
+
+
+ +
+ +
+
+ + fresh_commits(repo, n = 10) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 28
+def fresh_commits(repo, n = 10)
+  commits = repo.heads.map do |h|
+    repo.commits(h.name, n).map { |c| Commit.new(c, h) }
+  end.flatten.uniq { |c| c.id }
+
+  commits.sort! do |x, y|
+    y.committed_date <=> x.committed_date
+  end
+
+  commits[0...n]
+end
+
+
+ +
+ +
+
+ + new(raw_commit, head = nil) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 100
+def initialize(raw_commit, head = nil)
+  @commit = raw_commit
+  @head = head
+end
+
+
+ +
+ +
Instance Public methods
+ +
+
+ + author_email() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 117
+def author_email
+  author.email
+end
+
+
+ +
+ +
+
+ + author_name() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 121
+def author_name
+  author.name
+end
+
+
+ +
+ +
+
+ + committer_email() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 134
+def committer_email
+  committer.email
+end
+
+
+ +
+ +
+
+ + committer_name() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 130
+def committer_name
+  committer.name
+end
+
+
+ +
+ +
+
+ + created_at() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 113
+def created_at
+  committed_date
+end
+
+
+ +
+ +
+
+ + different_committer?() + + +
+ + +
+

Was this commit committed by a different person than the original author?

+
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 126
+def different_committer?
+  author_name != committer_name || author_email != committer_email
+end
+
+
+ +
+ +
+
+ + parents_count() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 146
+def parents_count
+  parents && parents.count || 0
+end
+
+
+ +
+ +
+
+ + prev_commit() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 138
+def prev_commit
+  parents.try :first
+end
+
+
+ +
+ +
+
+ + prev_commit_id() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 142
+def prev_commit_id
+  prev_commit.try :id
+end
+
+
+ +
+ +
+
+ + safe_message() + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 109
+def safe_message
+  @safe_message ||= message
+end
+
+
+ +
+ +
+
+ + short_id(length = 10) + + +
+ + +
+ +
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 105
+def short_id(length = 10)
+  id.to_s[0..length]
+end
+
+
+ +
+ +
+
+ + to_diff() + + +
+ + +
+

Shows the diff between the commit’s parent and the commit.

+ +

Cuts out the header and stats from to_patch and returns only the diff.

+
+ + + + + + +
+ + +
+
# File app/models/commit.rb, line 153
+def to_diff
+  # see Grit::Commit#show
+  patch = to_patch
+
+  # discard lines before the diff
+  lines = patch.split("\n")
+  while !lines.first.start_with?("diff --git") do
+    lines.shift
+  end
+  lines.pop if lines.last =~ %r^[\d.]+$/ # Git version
+  lines.pop if lines.last == "-- "      # end of diff
+  lines.join("\n")
+end
+
+
+ +
+
+ +
+ + \ No newline at end of file -- cgit v1.2.1