7

I'm building an application in Ruby on Rails 4 to handle git repositories, kind of like GitHub. One of the features is an in-app text editor with the option to commit your current changes. This is the part where I'm stuck. I need to use Rails to somehow get the changes, commit them, then push them to the remote.

The only thing I've thought of is using a Bash script to do this. The script would just be:

git add -A
git commit -m "Message that I get from user"
git push origin branch_name

The message and branch name would be variables that I get from the user.

For some reason, I don't think this would actually work.

Is it possible to use a Bash script to commit and push a Git repository with Rails? Is there a better, working method to do this?

9
  • 7
    github.com/schacon/ruby-git Remember, whatever you want to do, someone's probably already written a gem for it. Commented Sep 6, 2015 at 22:26
  • @MichaelHampton Gah, my Googlefu has failed me :P Commented Sep 6, 2015 at 22:27
  • It is a duplicate, but the answer here is more thorough, so even though the other one is older, I'd be tempted to close it in favour of this. Commented Sep 7, 2015 at 0:47
  • @MichaelHampton - can you make your comment an actual answer? I can't vote to close the older question until this one has an upvoted answer :) Commented Sep 7, 2015 at 0:48
  • @TarynEast I think you have that backwards. I posted an answer. :) Commented Sep 7, 2015 at 0:54

1 Answer 1

0

Most languages will let you execute command line expressions and capture the output. This might be lighter weight than installing a gem for every command you might want to run.

[1] Running command line commands within Ruby script

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.