Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
867301eb
Commit
867301eb
authored
Dec 23, 2021
by
Waqar Ahmed
Browse files
GitBlame: Show error on failure
Failing silently is really bad.
parent
33a748a4
Pipeline
#114478
passed with stage
in 3 minutes and 20 seconds
Changes
2
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
addons/git-blame/kategitblameplugin.cpp
View file @
867301eb
...
...
@@ -284,8 +284,24 @@ static int nextBlockStart(const QByteArray &out, int from)
return
next
;
}
void
KateGitBlamePluginView
::
blameFinished
(
int
/*exitCode*/
,
QProcess
::
ExitStatus
/*exitStatus*/
)
void
KateGitBlamePluginView
::
sendMessage
(
const
QString
&
text
,
bool
error
)
{
QVariantMap
genericMessage
;
genericMessage
.
insert
(
QStringLiteral
(
"type"
),
error
?
QStringLiteral
(
"Error"
)
:
QStringLiteral
(
"Info"
));
genericMessage
.
insert
(
QStringLiteral
(
"category"
),
i18n
(
"Git"
));
genericMessage
.
insert
(
QStringLiteral
(
"categoryIcon"
),
QIcon
(
QStringLiteral
(
":/icons/icons/sc-apps-git.svg"
)));
genericMessage
.
insert
(
QStringLiteral
(
"text"
),
text
);
Q_EMIT
message
(
genericMessage
);
}
void
KateGitBlamePluginView
::
blameFinished
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
)
{
if
(
exitCode
!=
0
||
exitStatus
!=
QProcess
::
NormalExit
)
{
QString
text
=
i18n
(
"Git blame failed."
);
sendMessage
(
text
+
QStringLiteral
(
"
\n
"
)
+
QString
::
fromUtf8
(
m_blameInfoProc
.
readAllStandardError
()),
true
);
return
;
}
QByteArray
out
=
m_blameInfoProc
.
readAllStandardOutput
();
out
.
replace
(
"
\r
"
,
""
);
// KTextEditor removes all \r characters in the internal buffers
// printf("recieved output: %d for: git %s\n", out.size(), qPrintable(m_blameInfoProc.arguments().join(QLatin1Char(' '))));
...
...
@@ -412,7 +428,8 @@ void KateGitBlamePluginView::blameFinished(int /*exitCode*/, QProcess::ExitStatu
void
KateGitBlamePluginView
::
showFinished
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
)
{
if
(
exitCode
!=
0
||
exitStatus
!=
QProcess
::
NormalExit
)
{
qWarning
()
<<
"Failed to show commit"
;
QString
text
=
i18n
(
"Git blame, show commit failed."
);
sendMessage
(
text
+
QStringLiteral
(
"
\n
"
)
+
QString
::
fromUtf8
(
m_showProc
.
readAllStandardError
()),
true
);
return
;
}
...
...
addons/git-blame/kategitblameplugin.h
View file @
867301eb
...
...
@@ -90,7 +90,10 @@ public:
void
showCommitTreeView
(
const
QUrl
&
url
);
Q_SIGNAL
void
message
(
const
QVariantMap
&
);
private:
void
sendMessage
(
const
QString
&
text
,
bool
error
);
void
viewChanged
(
KTextEditor
::
View
*
view
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment