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
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"`
Comments
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
Asara
the git repo is already there on the server where I wants to run the ruby script, I dont need to push, just commit.