Method: Grit::Index#commit
- Defined in:
- lib/grit/index.rb
#commit(message, parents = nil, actor = nil, last_tree = nil, head = 'master') ⇒ Object
Commit the contents of the index
+message+ is the commit message [nil]
+parents+ is one or more commits to attach this commit to to form a new head [nil]
+actor+ is the details of the user making the commit [nil]
+last_tree+ is a tree to compare with - to avoid making empty commits [nil]
+head+ is the branch to write this head to [master]
Returns a String of the SHA1 of the commit
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/grit/index.rb', line 48 def commit(, parents = nil, actor = nil, last_tree = nil, head = 'master') tree_sha1 = write_tree(self.tree, self.current_tree) return false if tree_sha1 == last_tree # don't write identical commits contents = [] contents << ['tree', tree_sha1].join(' ') parents.each do |p| contents << ['parent', p].join(' ') if p end if parents if actor name = actor.name email = actor.email else config = Config.new(self.repo) name = config['user.name'] email = config['user.email'] end = "#{name} <#{email}> #{Time.now.to_i} -0700" # !! TODO : gotta fix this contents << ['author', ].join(' ') contents << ['committer', ].join(' ') contents << '' contents << commit_sha1 = self.repo.git.ruby_git.put_raw_object(contents.join("\n"), 'commit') self.repo.update_ref(head, commit_sha1) end |