C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rugged-0.24.0/lib/rugged/repository.rb:22
4:in `push': Request failed with status code: 401 (Rugged::NetworkError)
from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rugged-0.24.0/lib/rugged/rep
ository.rb:224:in `push'
from mytest.rb:34:in `<main>'
下面是我的代码
require 'rugged'
git_email = '138XXXX@139.com'
git_name = 'XXXX'
repo_name = 'D://mytestcode//rubyOntest'
repo = Rugged::Repository.new('D://mytestcode//rubyOntest')
puts "1"
index = repo.index
puts "3"
oid = repo.write("This is a blob.", :blob)
#index.add(:path => "readme.txt", :oid => oid, :mode => 0100644)
index.add_all
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 => git_name, :time => Time.now }
puts "6"
options[:message] ||= "Making a commit via Rugged!--add all"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
puts "7"
objuser=Rugged::Credentials::UserPassword.new(options)
puts "8"
Rugged::Commit.create(repo, options)
puts "9"
repo.push 'origin'# this is my error
puts "Done"
波斯汪
Helenr
相关分类