如何使用< repository>和< refspec>选项调用rubygitpush命令?

s5a0g9ez  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(395)

这就是我指的图书馆:https://github.com/ruby-git/ruby-git
我正在尝试将以下命令转换为该库的git模块 git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo push --no-verify ssh://git.my.url/pkg/repo-name <commit_hash>:refs/heads/head 这就是我到目前为止所做的:

git = Git.clone(some_ssh_url)
  ... git add and git commit commands
  git.push(
    remote: "#{some_ssh_url}",
    branch: "#{git.revparse('HEAD~0').strip}:refs/heads/head",
    opts: { '--no-verify' => '' }
  )

这会产生以下错误:

Traceback (most recent call last):
    6: from /***:in `<main>'
    5: from /***:in `main'
    4: from /***:in `method_a'
    3: from /***:in `method_b'
    2: from /***:in `push'
    1: from /***/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/lib.rb:767:in `push'
/***/RubyGem-git/RubyGem-git-1.5.x.1579.0/AL2_x86_64/DEV.STD.PTHREAD/build/ruby2.7.x/lib/ruby/gems/2.7.0/gems/git-1.5.0/lib/git/lib.rb:967:in `command': git '--git-dir=/***/.git' '--work-tree=/***' push '{:opts=>{"--no-verify"=>"", "ssh://git.my.url/pkg/***"=>"", "<commit_hash>:refs/heads/head"=>""}}' 'master'  2>&1:error: src refspec master does not match any (Git::GitExecuteError)
error: failed to push some refs to '{:opts=>{"--no-verify"=>"", "ssh://git.my.url/pkg/***"=>"", "<commit_hash>:refs/heads/head"=>""}}'

不清楚我是否正确地翻译了命令,但是当我运行 git --git-dir=/path/to/repo/.git --work-tree=/path/to/repo push --no-verify ssh://git.my.url/pkg/repo-name <commit_hash>:refs/heads/head 具有 Open3 它通过了,所以我猜我在RubyGit中拥有的不是等价的。
有没有人使用过RubyGit,并且知道如何做类似的事情?

zhte4eai

zhte4eai1#

你不能https://github.com/ruby-git/ruby-git/blob/45aeac931b346cc73666ac03521ebfb0cd52fd93/lib/git/lib.rb#l886-l902
发送请求以扩展库。它是开源的:)

相关问题