Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to set up a system where, when I commit changes to my GitHub repository, my server also receives those commits.

To do that, I set my GitHub repo to send a post-receive hook to a URL on my rails app. I have a controller that will handle this.

The problem is this: how can I run git commands in a rails controller? I get how to do it in the command line.

Do I just type something like this:

# controller method where post-receive hook is sent
def commit
 git pull origin development
end
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
169 views
Welcome To Ask or Share your Answers For Others

1 Answer

Do this!

def commit
 system "git pull origin development"
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...