Commit 0767eb45 authored by Anthony Fieroni's avatar Anthony Fieroni

[git plugin] Add merge action

Differential Revision: https://phabricator.kde.org/D10213Signed-off-by: Anthony Fieroni's avatarAnthony Fieroni <bvbfan@abv.bg>
parent 92ea669a
......@@ -106,6 +106,10 @@ FileViewGitPlugin::FileViewGitPlugin(QObject* parent, const QList<QVariant>& arg
m_pullAction->setText(xi18nd("@action:inmenu", "<application>Git</application> Pull..."));
connect(m_pullAction, SIGNAL(triggered()),
this, SLOT(pull()));
m_mergeAction = new QAction(this);
m_mergeAction->setIcon(QIcon::fromTheme("merge"));
m_mergeAction->setText(xi18nd("@action:inmenu", "<application>Git</application> Merge..."));
connect(m_mergeAction, &QAction::triggered, this, &FileViewGitPlugin::merge);
m_logAction = new QAction(this);
m_logAction->setText(xi18nd("@action:inmenu", "<application>Git</application> Log..."));
......@@ -345,6 +349,7 @@ QList<QAction*> FileViewGitPlugin::contextMenuDirectoryActions(const QString& di
bool canCommit = false;
bool showChanges = false;
bool shouldMerge = false;
QHash<QString, ItemVersion>::const_iterator it = m_versionInfoHash.constBegin();
while (it != m_versionInfoHash.constEnd()) {
const ItemVersion state = it.value();
......@@ -357,6 +362,7 @@ QList<QAction*> FileViewGitPlugin::contextMenuDirectoryActions(const QString& di
if (state == ConflictingVersion) {
canCommit = false;
showChanges = true;
shouldMerge = true;
break;
}
++it;
......@@ -368,8 +374,13 @@ QList<QAction*> FileViewGitPlugin::contextMenuDirectoryActions(const QString& di
m_showLocalChangesAction->setEnabled(!m_pendingOperation && showChanges);
actions.append(m_showLocalChangesAction);
m_commitAction->setEnabled(!m_pendingOperation && canCommit);
actions.append(m_commitAction);
if (!shouldMerge) {
m_commitAction->setEnabled(!m_pendingOperation && canCommit);
actions.append(m_commitAction);
} else {
m_mergeAction->setEnabled(!m_pendingOperation);
actions.append(m_mergeAction);
}
m_tagAction->setEnabled(!m_pendingOperation);
actions.append(m_tagAction);
......@@ -484,6 +495,13 @@ void FileViewGitPlugin::log()
view->show();
}
void FileViewGitPlugin::merge()
{
Q_ASSERT(!m_contextDir.isEmpty());
KRun::runCommand(QStringLiteral("git mergetool"), nullptr, m_contextDir);
}
void FileViewGitPlugin::checkout()
{
CheckoutDialog dialog;
......
......@@ -58,6 +58,7 @@ private slots:
void pull();
void log();
void showDiff(const QUrl &link);
void merge();
void slotOperationCompleted(int exitCode, QProcess::ExitStatus exitStatus);
void slotOperationError();
......@@ -115,6 +116,7 @@ private:
QAction* m_pushAction;
QAction* m_pullAction;
QAction* m_logAction;
QAction* m_mergeAction;
QString m_currentDir;
QProcess m_process;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment