launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18555
[Merge] lp:~cjwatson/launchpad/git-job-logging into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/git-job-logging into lp:launchpad.
Commit message:
Give GitRefScanJobs a better __repr__.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-job-logging/+merge/258996
GitRefScanJob currently has a rather useless __repr__, which makes it difficult to investigate problems reported about a specific repository except by attempting to correlate timestamps. This adds the repository unique name so that we have a better chance of working out what's going on.
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-job-logging into lp:launchpad.
=== modified file 'lib/lp/code/model/gitjob.py'
--- lib/lp/code/model/gitjob.py 2015-03-20 12:32:55 +0000
+++ lib/lp/code/model/gitjob.py 2015-05-13 13:52:17 +0000
@@ -182,6 +182,11 @@
self._hosting_client = GitHostingClient(
config.codehosting.internal_git_api_endpoint)
+ def __repr__(self):
+ """Returns an informative representation of the job."""
+ return "<%s to scan refs in %s>" % (
+ self.__class__.__name__, self._cached_repository_name)
+
def run(self):
"""See `IGitRefScanJob`."""
try:
=== modified file 'lib/lp/code/model/tests/test_gitjob.py'
--- lib/lp/code/model/tests/test_gitjob.py 2015-03-20 14:54:23 +0000
+++ lib/lp/code/model/tests/test_gitjob.py 2015-05-13 13:52:17 +0000
@@ -126,6 +126,14 @@
repository = self.factory.makeGitRepository()
self.assertProvides(GitRefScanJob.create(repository), IGitRefScanJob)
+ def test___repr__(self):
+ # `GitRefScanJob` objects have an informative __repr__.
+ repository = self.factory.makeGitRepository()
+ job = GitRefScanJob.create(repository)
+ self.assertEqual(
+ "<GitRefScanJob to scan refs in %s>" % repository.unique_name,
+ repr(job))
+
def test_run(self):
# Ensure the job scans the repository.
repository = self.factory.makeGitRepository()
Follow ups