diff options
author | Lauren Perry <lauren.perry@codethink.co.uk> | 2015-01-08 17:20:31 +0000 |
---|---|---|
committer | Lauren Perry <lauren.perry@codethink.co.uk> | 2015-01-08 17:20:31 +0000 |
commit | e9f56a46f5ed8bc13c17e72c1d613bd46238a0e8 (patch) | |
tree | 502e3ddb97d95cb66a36dd03db48a568ea38b0b7 | |
parent | 385137f5b948ddb1899be245034063815881e308 (diff) | |
download | firehose-e9f56a46f5ed8bc13c17e72c1d613bd46238a0e8.tar.gz |
Log SHA of definitions to check whether it requires updating
-rw-r--r-- | firehose/plugin/firehose_plugin.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/firehose/plugin/firehose_plugin.py b/firehose/plugin/firehose_plugin.py index dd6f29b..343f6db 100644 --- a/firehose/plugin/firehose_plugin.py +++ b/firehose/plugin/firehose_plugin.py @@ -81,6 +81,7 @@ class FirehosePlugin(cliapp.Plugin): self.base_path = tfs.getsyspath("/") self.make_workspace() self.make_branch(confs[0].landing) + self.log_sha(os.path.basename(fname.replace('.yaml',''))) self.insert_githook() self.reset_to_tracking(confs[0].landing) self.load_morphologies() @@ -95,7 +96,7 @@ class FirehosePlugin(cliapp.Plugin): def make_workspace(self): self.app.subcommands['init']([self.make_path("ws")]) - def make_branch(self, root): + def make_branch(self, root, name): os.chdir(self.make_path("ws")) try: self.app.subcommands['branch']([root['repo'], root['myref'], root['baseref']]) @@ -107,6 +108,17 @@ class FirehosePlugin(cliapp.Plugin): repopath = root['repo'].replace(':', '/') self.gitpath = self.make_path("ws", root['myref'], repopath) + def log_sha(self, name): + sha = self.app.runcmd(['git', 'rev-parse', 'HEAD'], cwd=self.gitpath).strip() + filename = '/var/lib/firehose/'+name+'_log.json' + if (os.path.exists(os.path.abspath(filename))): + log = open(filename).read() + if sha in log: + print 'Everything up-to-date' + exit(0) + log = open(filename, 'w') + log.write('{\"sha\":\"'+sha+'\"}') + def insert_githook(self): scp_cmd = ('scp', '-p', '-P', '29418', 'firehose@testgerrit.baserock.org:hooks/commit-msg', self.gitpath+'/.git/hooks/commit-msg') |