Class: RJGit::Commit
- Inherits:
-
Object
- Object
- RJGit::Commit
- Defined in:
- lib/commit.rb
Instance Attribute Summary collapse
-
#actor ⇒ Object
readonly
Returns the value of attribute actor.
-
#authored_date ⇒ Object
readonly
Returns the value of attribute authored_date.
-
#committed_date ⇒ Object
readonly
Returns the value of attribute committed_date.
-
#committer ⇒ Object
readonly
Returns the value of attribute committer.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#jcommit ⇒ Object
readonly
Returns the value of attribute jcommit.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#parent_count ⇒ Object
readonly
Returns the value of attribute parent_count.
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
-
#short_message ⇒ Object
readonly
Returns the value of attribute short_message.
Class Method Summary collapse
- .diff(repo, a, b = nil, paths = [], options = {}) ⇒ Object
- .find_all(repository, ref, options) ⇒ Object
- .find_head(repository) ⇒ Object
-
.new_with_tree(repository, tree, message, actor, parents = nil) ⇒ Object
Pass an empty array for parents if the commit should have no parents.
Instance Method Summary collapse
-
#initialize(repository, commit) ⇒ Commit
constructor
A new instance of Commit.
- #tree ⇒ Object
Constructor Details
#initialize(repository, commit) ⇒ Commit
Returns a new instance of Commit.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/commit.rb', line 21 def initialize(repository, commit) @jrepo = RJGit.repository_type(repository) @jcommit = commit @id = ObjectId.to_string(commit.get_id) @actor = Actor.new_from_person_ident(@jcommit.) @committer = Actor.new_from_person_ident(@jcommit.get_committer_ident) @committed_date = Time.at(@jcommit.commit_time) = Time.at(@jcommit..when.time/1000) = @jcommit. = @jcommit. @parent_count = @jcommit.get_parent_count end |
Instance Attribute Details
#actor ⇒ Object (readonly)
Returns the value of attribute actor.
10 11 12 |
# File 'lib/commit.rb', line 10 def actor @actor end |
#authored_date ⇒ Object (readonly)
Returns the value of attribute authored_date.
12 13 14 |
# File 'lib/commit.rb', line 12 def end |
#committed_date ⇒ Object (readonly)
Returns the value of attribute committed_date.
13 14 15 |
# File 'lib/commit.rb', line 13 def committed_date @committed_date end |
#committer ⇒ Object (readonly)
Returns the value of attribute committer.
11 12 13 |
# File 'lib/commit.rb', line 11 def committer @committer end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/commit.rb', line 8 def id @id end |
#jcommit ⇒ Object (readonly)
Returns the value of attribute jcommit.
16 17 18 |
# File 'lib/commit.rb', line 16 def jcommit @jcommit end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
14 15 16 |
# File 'lib/commit.rb', line 14 def end |
#parent_count ⇒ Object (readonly)
Returns the value of attribute parent_count.
17 18 19 |
# File 'lib/commit.rb', line 17 def parent_count @parent_count end |
#parents ⇒ Object (readonly)
Returns the value of attribute parents.
9 10 11 |
# File 'lib/commit.rb', line 9 def parents @parents end |
#short_message ⇒ Object (readonly)
Returns the value of attribute short_message.
15 16 17 |
# File 'lib/commit.rb', line 15 def end |
Class Method Details
.diff(repo, a, b = nil, paths = [], options = {}) ⇒ Object
77 78 |
# File 'lib/commit.rb', line 77 def self.diff(repo, a, b = nil, paths = [], = {}) end |
.find_all(repository, ref, options) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/commit.rb', line 62 def self.find_all(repository, ref, ) repository = RJGit.repository_type(repository) return nil if repository.nil? begin walk = RevWalk.new(repository) objhead = repository.resolve(ref) root = walk.parse_commit(objhead) walk.mark_start(root) commits = walk.map { |commit| Commit.new(repository, commit) } return commits.first([:limit]) rescue NativeException => e return Array.new end end |
.find_head(repository) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/commit.rb', line 50 def self.find_head(repository) repository = RJGit.repository_type(repository) return nil if repository.nil? begin walk = RevWalk.new(repository) objhead = repository.resolve(Constants::HEAD) return Commit.new(repository, walk.parseCommit(objhead)) rescue NativeException => e return nil end end |
.new_with_tree(repository, tree, message, actor, parents = nil) ⇒ Object
Pass an empty array for parents if the commit should have no parents
43 44 45 46 47 48 |
# File 'lib/commit.rb', line 43 def self.new_with_tree(repository, tree, , actor, parents = nil) repository = RJGit.repository_type(repository) parents = parents ? parents : repository.resolve("refs/heads/#{Constants::MASTER}") new_commit = RJGit::Plumbing::Index.new(repository).do_commit(, actor, parents, tree) Commit.new(repository, RevWalk.new(repository).parseCommit(new_commit)) end |
Instance Method Details
#tree ⇒ Object
34 35 36 |
# File 'lib/commit.rb', line 34 def tree @tree ||= Tree.new(@jrepo, TREE_TYPE, nil, @jcommit.get_tree) end |