diff options
| author | Andre Hartmann <[email protected]> | 2024-11-24 13:05:27 +0100 |
|---|---|---|
| committer | André Hartmann <[email protected]> | 2025-02-13 08:39:08 +0000 |
| commit | 534362f99e3469606ff9ddb79ce7717d1ef20ca2 (patch) | |
| tree | 031e4f8f3a2c2ab00cb9f8fd8e3e999b9384d0c8 /src/plugins/git/instantblame.cpp | |
| parent | 9330e7a4bd3b47879721cc4c7dc907c07b660883 (diff) | |
Git: InstantBlame: Add "revert commit" action
Change-Id: I536bcff0c0edab33b57d53730f4b2b33ff30848f
Reviewed-by: Leena Miettinen <[email protected]>
Reviewed-by: Orgad Shaneh <[email protected]>
Diffstat (limited to 'src/plugins/git/instantblame.cpp')
| -rw-r--r-- | src/plugins/git/instantblame.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/plugins/git/instantblame.cpp b/src/plugins/git/instantblame.cpp index a1e174ee390..498bc42c1a9 100644 --- a/src/plugins/git/instantblame.cpp +++ b/src/plugins/git/instantblame.cpp @@ -9,6 +9,8 @@ #include "gitsettings.h" #include "gittr.h" +#include <coreplugin/icore.h> + #include <texteditor/textdocument.h> #include <texteditor/texteditor.h> #include <texteditor/texteditortr.h> @@ -27,6 +29,7 @@ #include <QLabel> #include <QLayout> #include <QLoggingCategory> +#include <QMessageBox> #include <QTextCodec> #include <QTimer> @@ -73,7 +76,7 @@ bool BlameMark::addToolTipContent(QLayout *target) const qCInfo(log) << "Link activated with target:" << link; const QString hash = (link == "blameParent") ? m_info.hash + "^" : m_info.hash; - if (link.startsWith("blame") || link == "showFile") { + if (link.startsWith("blame") || link == "revert" || link == "showFile") { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); const Utils::FilePath path = state.topLevel(); @@ -83,6 +86,15 @@ bool BlameMark::addToolTipContent(QLayout *target) const qCInfo(log).nospace().noquote() << "Blaming: \"" << path << "/" << originalFileName << "\":" << m_info.originalLine << " @ " << hash; gitClient().annotate(path, originalFileName, m_info.originalLine, hash); + } else if (link == "revert") { + const QMessageBox::StandardButton result = QMessageBox::question( + Core::ICore::dialogParent(), Tr::tr("Revert Commit?"), + Tr::tr("Revert the commit %1?").arg(m_info.hash.left(8)), + QMessageBox::Yes | QMessageBox::No); + if (result == QMessageBox::Yes) { + qCInfo(log).nospace().noquote() << "Reverting: \"" << path << "\" @ " << hash; + gitClient().synchronousRevert(path, hash); + } } else { qCInfo(log).nospace().noquote() << "Showing file: \"" << path << "/" << originalFileName << "\" @ " << hash; @@ -118,16 +130,18 @@ QString BlameMark::toolTipText(const CommitInfo &info) const const QString blameRevision = Tr::tr("Blame %1").arg(info.hash.left(8)); const QString blameParent = Tr::tr("Blame Parent"); const QString showFile = Tr::tr("File at %1").arg(info.hash.left(8)); + const QString revert = Tr::tr("Revert %1").arg(info.hash.left(8)); const QString logForLine = Tr::tr("Log for line %1").arg(info.line); actions = QString( "<table cellspacing=\"10\"><tr>" " <td><a href=\"blame\">%1</a></td>" " <td><a href=\"blameParent\">%2</a></td>" " <td><a href=\"showFile\">%3</a></td>" - " <td><a href=\"logLine\">%4</a></td>" + " <td><a href=\"revert\">%4</a></td>" + " <td><a href=\"logLine\">%5</a></td>" "</tr></table>" "<p></p>") - .arg(blameRevision, blameParent, showFile, logForLine); + .arg(blameRevision, blameParent, showFile, revert, logForLine); } const QString header = QString( |
