diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-04-08 08:59:42 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-04-08 11:46:25 +0000 |
commit | 967753ece20087297cacf26f5e08bf555a2e6868 (patch) | |
tree | 501cba957cb2046fd798a6f0ae7c359c1b2c0350 /morphlib/gitdir.py | |
parent | c04760ffe1d385134e5092a22db5e5f78c205038 (diff) | |
download | morph-967753ece20087297cacf26f5e08bf555a2e6868.tar.gz |
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 <morphlib.gitdir.Remote object at 0x905096c>,
push url None with refspecs (<morphlib.gitdir.RefSpec object at 0xf72fec2c>,)
failed with exit code 128
Becomes:
ERROR: Push to remote "origin", push url None failed with exit code 128
Diffstat (limited to 'morphlib/gitdir.py')
-rw-r--r-- | morphlib/gitdir.py | 14 |
1 files changed, 8 insertions, 6 deletions
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: |