forked from qt-creator/qt-creator
Git: Enable different reset types for commits in git editors
Change-Id: I0eafbd3db04a7da4ea85457ae67a940c71b49e9b Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
1eeca66c29
commit
690a545f8e
@@ -212,12 +212,13 @@ void GitEditorWidget::checkoutChange()
|
|||||||
sourceWorkingDirectory(), m_currentChange);
|
sourceWorkingDirectory(), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::resetChange()
|
void GitEditorWidget::resetChange(const QByteArray &resetType)
|
||||||
{
|
{
|
||||||
const QString workingDir = sourceWorkingDirectory();
|
const QString workingDir = sourceWorkingDirectory();
|
||||||
|
|
||||||
GitClient *client = GitPlugin::instance()->gitClient();
|
GitClient *client = GitPlugin::instance()->gitClient();
|
||||||
if (client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
|
if (resetType == "hard"
|
||||||
|
&& client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules))
|
||||||
!= GitClient::StatusUnchanged) {
|
!= GitClient::StatusUnchanged) {
|
||||||
if (QMessageBox::question(
|
if (QMessageBox::question(
|
||||||
Core::ICore::mainWindow(), tr("Reset"),
|
Core::ICore::mainWindow(), tr("Reset"),
|
||||||
@@ -227,7 +228,7 @@ void GitEditorWidget::resetChange()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client->reset(workingDir, QLatin1String("--hard"), m_currentChange);
|
client->reset(workingDir, QLatin1String("--" + resetType), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::cherryPickChange()
|
void GitEditorWidget::cherryPickChange()
|
||||||
@@ -348,7 +349,14 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
|||||||
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
|
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
|
||||||
menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange()));
|
menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange()));
|
||||||
menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange()));
|
menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange()));
|
||||||
menu->addAction(tr("Hard &Reset to Change %1").arg(change), this, SLOT(resetChange()));
|
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
||||||
|
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered,
|
||||||
|
this, [this]() { resetChange("hard"); });
|
||||||
|
connect(resetMenu->addAction(tr("&Mixed")), &QAction::triggered,
|
||||||
|
this, [this]() { resetChange("mixed"); });
|
||||||
|
connect(resetMenu->addAction(tr("&Soft")), &QAction::triggered,
|
||||||
|
this, [this]() { resetChange("soft"); });
|
||||||
|
menu->addMenu(resetMenu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,13 +56,13 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkoutChange();
|
void checkoutChange();
|
||||||
void resetChange();
|
|
||||||
void cherryPickChange();
|
void cherryPickChange();
|
||||||
void revertChange();
|
void revertChange();
|
||||||
void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert);
|
void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
void resetChange(const QByteArray &resetType);
|
||||||
void addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk);
|
void addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk);
|
||||||
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||||
QSet<QString> annotationChanges() const;
|
QSet<QString> annotationChanges() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user