forked from qt-creator/qt-creator
Git: Support different reset types in branches view
Change-Id: Idce57062cbb92edd4c26647aabef040ec92b9f3c Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
2c5808bada
commit
a33386e014
@@ -230,8 +230,11 @@ void BranchView::slotCustomContextMenu(const QPoint &point)
|
|||||||
contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); });
|
contextMenu.addAction(tr("&Log"), this, [this] { log(selectedIndex()); });
|
||||||
contextMenu.addSeparator();
|
contextMenu.addSeparator();
|
||||||
if (!currentSelected) {
|
if (!currentSelected) {
|
||||||
if (currentLocal)
|
auto resetMenu = new QMenu(tr("Re&set"), &contextMenu);
|
||||||
contextMenu.addAction(tr("Re&set"), this, &BranchView::reset);
|
resetMenu->addAction(tr("&Hard"), this, [this] { reset("hard"); });
|
||||||
|
resetMenu->addAction(tr("&Mixed"), this, [this] { reset("mixed"); });
|
||||||
|
resetMenu->addAction(tr("&Soft"), this, [this] { reset("soft"); });
|
||||||
|
contextMenu.addMenu(resetMenu);
|
||||||
QString mergeTitle;
|
QString mergeTitle;
|
||||||
if (isFastForwardMerge()) {
|
if (isFastForwardMerge()) {
|
||||||
contextMenu.addAction(tr("&Merge (Fast-Forward)"), this, [this] { merge(true); });
|
contextMenu.addAction(tr("&Merge (Fast-Forward)"), this, [this] { merge(true); });
|
||||||
@@ -466,17 +469,17 @@ bool BranchView::rename()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BranchView::reset()
|
bool BranchView::reset(const QByteArray &resetType)
|
||||||
{
|
{
|
||||||
const QString currentName = m_model->fullName(m_model->currentBranch());
|
const QString currentName = m_model->fullName(m_model->currentBranch());
|
||||||
const QString branchName = m_model->fullName(selectedIndex());
|
const QString branchName = m_model->fullName(selectedIndex());
|
||||||
if (currentName.isEmpty() || branchName.isEmpty())
|
if (currentName.isEmpty() || branchName.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?")
|
if (QMessageBox::question(this, tr("Git Reset"), tr("Reset branch \"%1\" to \"%2\"?")
|
||||||
.arg(currentName).arg(branchName),
|
.arg(currentName).arg(branchName),
|
||||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
GitPlugin::client()->reset(m_repository, "--hard", branchName);
|
GitPlugin::client()->reset(m_repository, QLatin1String("--" + resetType), branchName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ private:
|
|||||||
bool checkout();
|
bool checkout();
|
||||||
bool remove();
|
bool remove();
|
||||||
bool rename();
|
bool rename();
|
||||||
bool reset();
|
bool reset(const QByteArray &resetType);
|
||||||
bool isFastForwardMerge();
|
bool isFastForwardMerge();
|
||||||
bool merge(bool allowFastForward);
|
bool merge(bool allowFastForward);
|
||||||
void rebase();
|
void rebase();
|
||||||
|
|||||||
Reference in New Issue
Block a user