1

I'm currently working on a command-line ruby gem that automates the "rebase + no-ff merging" workflow discussed at https://gist.github.com/jbenet/ee6c9ac48068889b0912. You can find the WIP code for this gem at https://github.com/gsmendoza/git_pretty_accept/tree/git_pretty_accept. The gem would do something like this:

git co master
git pull
git co pull_request
git rebase master
git co master
git merge --edit --no-ff pull_request
git push
git branch -d pull_request
git push origin:pull_request

When I try to run these git commands via ruby, git merge --edit --no-ff pull_request doesn't open the git commit message editor like I hope it would. Instead, I think git just receives a blank merge message from the editor and ruby continues with the rest of the script.

Any ideas?

1 Answer 1

0

Just read your code.

`git merge --no-ff --message "#{merge_message}" #{branch}`

In Ruby, this backtick syntax redirects the STDIN and STDOUT.

Simply try this instead:

system("git merge --edit --no-ff #{branch}")

The system function just forks a process and wait for the subprocess finish, without touching STDIN/STDOUT. I tested and it works.

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

3 Comments

Yeah, I tweaked the git merge call in this question. In the gem, I used the --message option. However, I would prefer to use --edit instead. Will still try using system instead of backticks because that was also what was recommended in this separate question (stackoverflow.com/questions/19873593/…). Thanks!
Edited. I have tried --edit before answering and it works. Just copy & paste mistake.
It does! And I thought I needed to call some IO.pipe magicky :)

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.