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.addSeparator();
|
||||
if (!currentSelected) {
|
||||
if (currentLocal)
|
||||
contextMenu.addAction(tr("Re&set"), this, &BranchView::reset);
|
||||
auto resetMenu = new QMenu(tr("Re&set"), &contextMenu);
|
||||
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;
|
||||
if (isFastForwardMerge()) {
|
||||
contextMenu.addAction(tr("&Merge (Fast-Forward)"), this, [this] { merge(true); });
|
||||
@@ -466,17 +469,17 @@ bool BranchView::rename()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BranchView::reset()
|
||||
bool BranchView::reset(const QByteArray &resetType)
|
||||
{
|
||||
const QString currentName = m_model->fullName(m_model->currentBranch());
|
||||
const QString branchName = m_model->fullName(selectedIndex());
|
||||
if (currentName.isEmpty() || branchName.isEmpty())
|
||||
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),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
GitPlugin::client()->reset(m_repository, "--hard", branchName);
|
||||
GitPlugin::client()->reset(m_repository, QLatin1String("--" + resetType), branchName);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
bool checkout();
|
||||
bool remove();
|
||||
bool rename();
|
||||
bool reset();
|
||||
bool reset(const QByteArray &resetType);
|
||||
bool isFastForwardMerge();
|
||||
bool merge(bool allowFastForward);
|
||||
void rebase();
|
||||
|
||||
Reference in New Issue
Block a user