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?

Asara
  • 2,791
  • 3
  • 26
  • 55

2 Answers2

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"`
Preston
  • 163
  • 1
  • 8
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.)

max pleaner
  • 26,189
  • 9
  • 66
  • 118
mahemoff
  • 44,526
  • 36
  • 160
  • 222
  • the git repo is already there on the server where I wants to run the ruby script, I dont need to push, just commit. – Asara Oct 10 '17 at 23:39