问题描述
我在脚本中使用脚本来推送git,所以我选择Rugged做到这一点,当我尝试推送回购时,我遇到了问题,它给了我错误,您能帮我吗?
require'rugged'
git_email ='[email protected]'
git_name ='Nizar'
repo_name ='/ Users / euphor / Desktop / test / testignore1'
repo = Rugged :: Repository.new('/ Users / euphor / Desktop / test / testignore1')
puts1
index = repo.index
puts3
oid = repo.write(This is a blob :,blob)
index.add(:path =>testignore1,:oid => oid,:mode => 0100644)
放置4
options = {}
options [:tree] = index.write_tree(repo)
puts5
options [:author] = {:email => ; git_email,:name => git_name,:time => Time.now}
options [:committer] = {:email => git_email,:name => 'Test Author',:time => Time.now}
放置6
选项[:message] || =通过Rugged进行提交!
选项[:父母] = repo.empty? ? []:[repo.head.target] .compact
options [:update_ref] ='HEAD'
puts7
Rugged :: Commit.create(repo,options)
放置8
** repo.push'origin'**#这是我的错误
放置完成
我的错误信息是:
看起来像是libgit2(后端为Rugged)未正确安装。如果使用Homebrew,您可以在Mac OS上使用最方便的打包解决方案,并且您需要它来安装额外的库。
安装Homebrew
执行此行后按照屏幕上的指示操作:
ruby -e$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
安装openssh
brew install openssh
重新安装耐用的宝石
宝石卸载坚固的
gem install rugged
现在您的代码段应该可以正常运行。
I worked in a script to push to git using a script, so I choose Rugged to do that, my probleme when I try to push to repo, it gives me error, Can you help me ?
require 'rugged'
git_email = '[email protected]'
git_name = 'Nizar'
repo_name = '/Users/euphor/Desktop/test/testignore1'
repo = Rugged::Repository.new('/Users/euphor/Desktop/test/testignore1')
puts "1"
index = repo.index
puts "3"
oid = repo.write("This is a blob.", :blob)
index.add(:path => "testignore1", :oid => oid, :mode => 0100644)
puts "4"
options = {}
options[:tree] = index.write_tree(repo)
puts "5"
options[:author] = { :email => git_email, :name => git_name, :time => Time.now }
options[:committer] = { :email => git_email, :name => 'Test Author', :time => Time.now }
puts "6"
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
puts "7"
Rugged::Commit.create(repo, options)
puts "8"
**repo.push 'origin'** # this is my error
puts "Done"
the message of my error is :
Looks like you have libgit2 (backend for Rugged) not installed properly. Most convenient packaging solution for Mac OS if Homebrew, and you need it to install additional libraries.
Install Homebrew
Follow any on-screen instructions after executing this line:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install openssh
brew install openssh
Reinstall rugged gem
gem uninstall rugged
gem install rugged
Now your snippet should run fine.
这篇关于使用Rugged推入Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!