0

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})
Equinox
  • 11
  • 6
  • I did a search on [rugged github](https://github.com/libgit2/rugged) for save. There is not currently any such command. Neither is there a save command defined in libgit2 (I searched that repository too). Your documentation is for version 0.19.0. The latest version is [0.25.0b1](https://rubygems.org/gems/rugged/versions/0.25.0b1) – MikeJRamsey56 Apr 14 '16 at 18:32
  • Ho ! you're right ^^' But when i'm doing a repo update, only my git log is update, I didn't know how to really update my folder.. :/ – Equinox Apr 15 '16 at 20:42
  • Look at this Stackoverflow [Q&A](http://stackoverflow.com/questions/31807493/push-to-git-using-rugged). Also, browse the tests on the Rugged [github site](https://github.com/libgit2/rugged/tree/master/test) for examples. – MikeJRamsey56 Apr 15 '16 at 21:06

0 Answers0