diff --git a/GitAutoDeploy.conf.json.example b/GitAutoDeploy.conf.json.example index 35aba2d..d973c72 100644 --- a/GitAutoDeploy.conf.json.example +++ b/GitAutoDeploy.conf.json.example @@ -4,6 +4,7 @@ [{ "url": "https://github.com/logsol/Test-Repo", "path": "/home/logsol/projects/Test-Repo", + "gitcmd": "git fetch && git reset --hard origin/master && git clean -df && git checkout master", "deploy": "echo deploying" }, { diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 1e61cc6..1692677 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -77,10 +77,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): config = self.getConfig() diff --git a/README.textile b/README.textile index 4dff7fb..3122972 100644 --- a/README.textile +++ b/README.textile @@ -23,7 +23,7 @@ When someone pushes changes into Github, it sends a json file to the service hoo 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 fetch". +move there and run your desired git command. Additionally it runs a deploy bash command that you can add to the config file optionally. Make sure that you start the server as the user that is allowed to pull from the github repository.