From 967753ece20087297cacf26f5e08bf555a2e6868 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Tue, 8 Apr 2014 08:59:42 +0000 Subject: Tweak some user-facing error messages in 'gitdir' The default Python __repr__() is useless for both developers and users, so avoid using it in error messages. The following message: ERROR: Push to remote , push url None with refspecs (,) failed with exit code 128 Becomes: ERROR: Push to remote "origin", push url None failed with exit code 128 --- morphlib/gitdir.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'morphlib') diff --git a/morphlib/gitdir.py b/morphlib/gitdir.py index 3d0ab53e..8f6d69d7 100644 --- a/morphlib/gitdir.py +++ b/morphlib/gitdir.py @@ -108,23 +108,22 @@ class PushError(cliapp.AppException): class NoRefspecsError(PushError): def __init__(self, remote): - self.remote = remote.name - PushError.__init__(self, - 'Push to remote %r was given no refspecs.' % remote) + self.remote = remote + PushError.__init__( + self, 'Push to remote "%s" was given no refspecs.' % remote) class PushFailureError(PushError): def __init__(self, remote, refspecs, exit, results, stderr): - self.remote = remote.name + self.remote = remote self.push_url = push_url = remote.get_push_url() self.refspecs = refspecs self.exit = exit self.results = results self.stderr = stderr - PushError.__init__(self, 'Push to remote %(remote)r, '\ + PushError.__init__(self, 'Push to remote "%(remote)s", '\ 'push url %(push_url)s '\ - 'with refspecs %(refspecs)r '\ 'failed with exit code %(exit)s' % locals()) @@ -235,6 +234,9 @@ class Remote(object): self.push_url = None self.fetch_url = None + def __str__(self): + return self.name or '(nascent remote)' + def set_fetch_url(self, url): self.fetch_url = url if self.name is not None: -- cgit v1.2.1