0

Why this Ruby code doesn't work? It's supposed to clone a git repository from a remote server.

pipe = IO.popen( 'git clone [email protected]:/prj/Common/git/MyProject', "w+"  )
pipe.puts 'mySecretPassword'
pipe.close_write

Thanks.

4
  • 1
    could you kindly tell us how exactly it doesn't work - the output, errors etc Commented Feb 10, 2012 at 9:13
  • Sorry. You're right. The problem is... there is no error at all, but git doesn't get the password I provide with pipe.puts Commented Feb 10, 2012 at 9:34
  • Finally I got the problem, but not the solution. The problem is GIT reads the password from the screen and not on the standard input. How can I solve this? Commented Feb 10, 2012 at 11:18
  • Setting GIT_ASKPASS to a script that provides the password doesn't work. I'm afraid my question was incomplete: I omitted to write that the server is configured to use SSH. Commented Feb 10, 2012 at 15:52

2 Answers 2

3

I don't know why it's not working but if you want to work with Git repo in your Ruby app it's good idea to use one of Gems that provide API for Git (i.e. git).

Sign up to request clarification or add additional context in comments.

1 Comment

The gem you suggested can't clone a remote repository: you cannot provide a password. I'm afraid your answer is not so useful, sorry.
0

I'd use a git wrapper for ruby such as this one. Makes everything simpler https://github.com/libgit2/rugged

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.