Skip to content

Commit

Permalink
add git_cmd to conf: logsol#29
Browse files Browse the repository at this point in the history
  • Loading branch information
glaslos committed Nov 20, 2015
1 parent b61eb07 commit 1196049
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ You can even test the whole thing here, by clicking on the "Test Hook" button, w
When someone pushes changes into Github, it sends a json file to the service hook url.
It contains information about the repository that was updated.

All it really does is match the repository urls to your local repository paths in the config file,move there and run "git pull".
All it really does is match the repository urls to your local repository paths in the config file, move there and run your desired git command.


Additionally it runs deploy bash commands that you can add to the config file optionally.
Expand Down
1 change: 1 addition & 0 deletions git_deploy.conf.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[{
"url": "https://github.com/",
"path": "/opt/",
"gitcmd": "git fetch && git reset --hard origin/master && git clean -df && git checkout master",
"deploy": [
"pip install -r requirements.txt",
"supervisorctl restart service"
Expand Down
9 changes: 8 additions & 1 deletion git_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,17 @@ def respond(self, code):
self.end_headers()

def fetch(self, path):
gitcmd = 'git fetch'
config = self.getConfig()
for repository in config['repositories']:
if repository['path'] == path:
if 'gitcmd' in repository:
gitcmd = repository['gitcmd']
break
if not self.quiet:
print("\nPost push request received")
print('Updating ' + path)
call(['cd "' + path + '" && git fetch'], shell=True)
call(['cd "' + path + '" && ' + gitcmd], shell=True)

def deploy(self, path):
self.get_config()
Expand Down

0 comments on commit 1196049

Please sign in to comment.