Skip to content

Instantly share code, notes, and snippets.

@sandinist
Created September 26, 2012 12:05
Show Gist options
  • Save sandinist/3787637 to your computer and use it in GitHub Desktop.
Save sandinist/3787637 to your computer and use it in GitHub Desktop.
require 'bundler/setup'
Bundler.require
repo = Rugged::Repository.new('.')
p repo
p repo.head
#ToDo modify txt
#data = File.read(./rugged_test)
repo.index.add('rugged_test')
repo.index.write
builder = Rugged::Tree::Builder.new
repo.index.entries.each do |entry|
builder << {
type: :blob,
name: entry[:path],
oid: entry[:oid],
filemode: entry[:mode]
}
end
tree_sha = builder.write(repo)
author = {
name: 'sandinist',
email: 'sandinista21@gmail.com',
time: Time.now
}
id = Rugged::Commit.create(repo,
message: "from rugged\n",
committer: author,
author: author,
parents: [repo.head.target],
tree: tree_sha,
update_ref: 'HEAD'
)
p id
source :rubygems
gem 'rugged', '0.17.0.b6'
GEM
remote: http://rubygems.org/
specs:
rugged (0.17.0.b6)
PLATFORMS
ruby
DEPENDENCIES
rugged (= 0.17.0.b6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment