From 570e111349afda436e131287a81b32952577b7ad Mon Sep 17 00:00:00 2001 From: Thomas Dietrich Date: Wed, 3 Jun 2015 14:18:16 +0200 Subject: [PATCH 1/4] variable git command in conf file --- GitAutoDeploy.conf.json.example | 1 + GitAutoDeploy.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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..52bcc1c 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -80,7 +80,7 @@ def fetch(self, path): if(not self.quiet): print "\nPost push request received" print 'Updating ' + path - call(['cd "' + path + '" && git fetch'], shell=True) + call(['cd "' + path + '" && ' + repository['gitcmd']], shell=True) def deploy(self, path): config = self.getConfig() From 39a84c42a57ef5d7affea1309eb1a6d781f1654b Mon Sep 17 00:00:00 2001 From: Thomas Dietrich Date: Wed, 3 Jun 2015 14:31:58 +0200 Subject: [PATCH 2/4] variable git command in conf file - README updated --- README.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From d88e4da0a8ee458457efe4ef91d373e3a0983df8 Mon Sep 17 00:00:00 2001 From: Thomas Dietrich Date: Wed, 3 Jun 2015 14:41:59 +0200 Subject: [PATCH 3/4] variable git command in conf file - config access --- GitAutoDeploy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 52bcc1c..527e7e2 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 + '" && ' + repository['gitcmd']], shell=True) + call(['cd "' + path + '" && ' + gitcmd], shell=True) def deploy(self, path): config = self.getConfig() From a8bc9e67aab18bcbfdac5406815216a6e72d5017 Mon Sep 17 00:00:00 2001 From: Thomas Dietrich Date: Wed, 3 Jun 2015 14:45:00 +0200 Subject: [PATCH 4/4] tab-to-space-conversion --- GitAutoDeploy.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 527e7e2..1692677 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -77,12 +77,12 @@ def respond(self, code): self.end_headers() def fetch(self, path): - gitcmd = 'git fetch' - config = self.getConfig() + gitcmd = 'git fetch' + config = self.getConfig() for repository in config['repositories']: if(repository['path'] == path): if 'gitcmd' in repository: - gitcmd = repository['gitcmd'] + gitcmd = repository['gitcmd'] break if(not self.quiet): print "\nPost push request received"