So, I wanted to perform a git pull with rugged, so I make a fetch and merge like this:
require 'rugged'
certificat = Rugged::Credentials::SshKey.new({username: 'git', privatekey: 'path/to/privatekey', publickey: 'path/to/publickey' })
repo = Rugged::Repository.new("/tmp/git")
repo.checkout('master')
# git fetch
remote = repo.remotes['origin']
remote.fetch(credentials: certificat)
remote.save # save new data
# git merge
commit = repo.branches['origin/master'].target
repo.references.update(repo.head, commit.oid)
But I have this error with the save method:
undefined method `save' for #<Rugged::Remote:0x0000000135d6e8> (NoMethodError)
I don't understand why especially that the save method is in the Rugged doc (here)
Somebody know why ?
EDIT: Ok, so this documentation is outdated, the method save doesn't exist anymore. I think my merge is imcomplete, somebody know ?
EDIT2: I just add this line at the end of this code and it's work !
repo.checkout_head({strategy: :force})