使用 tty-命令 gem 将密码写入控制台



我正在使用这个 gem 来运行git clone但它要求我输入密码,我需要知道正确的方法来执行此操作

我正在尝试这种方式,但它不起作用

in_stream = StringIO.new
in_stream.puts "password"
in_stream.rewind
cmd = TTY::Command.new
git_clone = "git clone https://user@bitbucket.org/repository.git '/home/user/aplication/my-project'"
cmd.run(git_clone, in: in_stream).out

我收到此错误

fatal: could not read Password for 'https://user@bitbucket.org': Device or address does not exist

我该如何解决这个问题?

这完全是处理这个 IMO 的错误方式。使用为作业构建的工具。使用一个实际的 Ruby git 库,比如 ruby-git。

最新更新