如何使用 <repository> 和 <refspec> 选项调用 ruby-git 推送命令?
How do you call the ruby-git push command with <repository> and <refspec> options?
这是我指的图书馆: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
它通过时,所以我的猜测是我在 ruby-git 不等价。
有没有人使用过 ruby-git,并且知道如何做类似 here 中描述的事情?
这是我指的图书馆: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
它通过时,所以我的猜测是我在 ruby-git 不等价。
有没有人使用过 ruby-git,并且知道如何做类似 here 中描述的事情?