Method: Cir::GitRepository#commit
- Defined in:
- lib/cir/git_repository.rb
#commit(message = nil) ⇒ Object
Commit all staged changes to the git repository
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cir/git_repository.rb', line 64 def commit( = nil) # Write current index back to the repository index = @repo.index commit_tree = index.write_tree @repo # Commit message files = [] index.each {|i| files << File.basename(i[:path]) } = "Affected files: #{files.join(', ')}" if .nil? # User handling user = ENV['USER'] user = "cir-out-commit" if user.nil? # Commit author structure for git = { email: '[email protected]', name: user, time: Time.now } # And finally commit itself Rugged::Commit.create @repo, author: , committer: , message: , parents: @repo.empty? ? [] : [ @repo.head.target ].compact, tree: commit_tree, update_ref: 'HEAD' end |