From 266bf68d477fb20edee843eb60867bdcad210ad8 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sat, 30 Mar 2019 20:50:58 -0500 Subject: [PATCH] Implement a get_repository_name function to use with the Jenkins function. --- lugito/lugito.py | 14 ++++++++++++++ lugito/webhooks.py | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lugito/lugito.py b/lugito/lugito.py index 92412e8..930e53c 100644 --- a/lugito/lugito.py +++ b/lugito/lugito.py @@ -157,6 +157,20 @@ class Lugito(object): return self.phab.phid.query(phids=[phid])[phid][key] + def get_repository_name(self): #pragma: no cover + # Get the commit PHID and search it + commit_phid = self.request_data["object"]["phid"] + commit = phab.diffusion.commit.search( + constraints={"phids": [commit_phid]}) + + # Grab the repository PHID from the query results + repo_phid = commit["data"][0]["fields"]["repositoryPHID"] + + # Using the repo PHID we just grabbed, get the name of it + repo_name = phab.phid.query(phids=[repo_phid])[repo_phid]["name"] + return repo_name + + def get_commit_message(self): """ Get the commit message diff --git a/lugito/webhooks.py b/lugito/webhooks.py index 1b9bc28..4daf3b5 100644 --- a/lugito/webhooks.py +++ b/lugito/webhooks.py @@ -178,7 +178,7 @@ def jenkinstrigger(): return 'Ok' object_type = lugito.request_data["object"]["type"] - pkg_name = lugito.get_object_string("name") + pkg_name = lugito.get_repository_name() if object_type == "CMIT": logger.debug("Object is a commit.")