Skip to content

Commit

Permalink
remote: Show an error message when 'Push' fails
Browse files Browse the repository at this point in the history
"git push" might fail but we provide no indication of this to
the user.  Show a helpful error message when this happens.

Closes #69

Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed May 20, 2011
1 parent f849eee commit 8124f27
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cola/controllers/remote.py
Expand Up @@ -209,5 +209,12 @@ def remote_callback():
output = self.tr('Already up-to-date.')
# Force the status to 1 so that we always display the log
qtutils.log(1, output)

if status != 0 and action == 'push':
message = 'Error pushing to "%s".\n\nPull first?' % remote
qtutils.critical('Push Error',
message=message, details=output)

self.view.accept()

return remote_callback
19 changes: 19 additions & 0 deletions cola/qtutils.py
Expand Up @@ -90,6 +90,25 @@ def information(title, message=None):
parent = QtGui.QApplication.instance().activeWindow()
QtGui.QMessageBox.information(parent, title, message)


def critical(title, message=None, details=None):
"""Show a warning with the provided title and message."""
if message is None:
message = title
title = tr(title)
message = tr(message)
parent = QtGui.QApplication.instance().activeWindow()
mbox = QtGui.QMessageBox(parent)
mbox.setWindowTitle(title)
mbox.setTextFormat(QtCore.Qt.PlainText)
mbox.setText(message)
mbox.setIcon(QtGui.QMessageBox.Critical)
mbox.setStandardButtons(QtGui.QMessageBox.Close)
mbox.setDefaultButton(QtGui.QMessageBox.Close)
if details:
mbox.setDetailedText(details)
mbox.exec_()

# Register globally with the notifier
cola.notifier().connect(signals.information, information)

Expand Down

0 comments on commit 8124f27

Please sign in to comment.