1

I want to dave or change a file with ruby, thats no problem. But this file is part of a git repository that needs to be commited after the change. How can I achieve that with the ruby script?

2 Answers 2

4

Call a shell command in your ruby script. There are lots of ways to execute a shell command in ruby. Backticks are one of them. Look at this Calling shell commands from Ruby for more.

`git commit -am "Committing from ruby script"`
Sign up to request clarification or add additional context in comments.

Comments

1

Just use a Git library like ruby-git- establish the repo in a temp folder, pull the project into it, change the file, commit it, push it, and delete the repo. (Assuming it's a rare operation. If not, you should probably establish a permanent repo folder and just keep pulling, committing, and pushing it.)

1 Comment

the git repo is already there on the server where I wants to run the ruby script, I dont need to push, just commit.

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.