forked from qt-creator/qt-creator
Git: Start interactive rebase from log window
Useful if local changes are already pushed to a remote and therefore Creator refuses interactive rebase due to missing local commits. Task-number: QTCREATORBUG-11200 Change-Id: I2e9b9fd35b75fcb232c1358c553fe1092ce97161 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
cb8da0e93b
commit
d2d05c584e
@@ -303,6 +303,10 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
||||
menu->addAction(tr("C&heckout Change %1").arg(change), this, [this] {
|
||||
GitPlugin::client()->checkout(sourceWorkingDirectory(), m_currentChange);
|
||||
});
|
||||
connect(menu->addAction(tr("&Interactive Rebase from Change %1...").arg(change)),
|
||||
&QAction::triggered, this, [this] {
|
||||
GitPlugin::instance()->startRebaseFromCommit(sourceWorkingDirectory(), m_currentChange);
|
||||
});
|
||||
menu->addAction(tr("&Log for Change %1").arg(change), this, [this] {
|
||||
GitPlugin::client()->log(sourceWorkingDirectory(), QString(), false, {m_currentChange});
|
||||
});
|
||||
|
@@ -816,20 +816,31 @@ void GitPlugin::recoverDeletedFiles()
|
||||
|
||||
void GitPlugin::startRebase()
|
||||
{
|
||||
if (!DocumentManager::saveAllModifiedDocuments())
|
||||
return;
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
const QString topLevel = state.topLevel();
|
||||
if (topLevel.isEmpty() || !m_gitClient->canRebase(topLevel))
|
||||
|
||||
startRebaseFromCommit(topLevel, QString());
|
||||
}
|
||||
|
||||
void GitPlugin::startRebaseFromCommit(const QString &workingDirectory, QString commit)
|
||||
{
|
||||
if (!DocumentManager::saveAllModifiedDocuments())
|
||||
return;
|
||||
LogChangeDialog dialog(false, ICore::dialogParent());
|
||||
RebaseItemDelegate delegate(dialog.widget());
|
||||
dialog.setWindowTitle(tr("Interactive Rebase"));
|
||||
if (!dialog.runDialog(topLevel))
|
||||
if (workingDirectory.isEmpty() || !m_gitClient->canRebase(workingDirectory))
|
||||
return;
|
||||
if (m_gitClient->beginStashScope(topLevel, "Rebase-i"))
|
||||
m_gitClient->interactiveRebase(topLevel, dialog.commit(), false);
|
||||
|
||||
if (commit.isEmpty()) {
|
||||
LogChangeDialog dialog(false, ICore::dialogParent());
|
||||
RebaseItemDelegate delegate(dialog.widget());
|
||||
dialog.setWindowTitle(tr("Interactive Rebase"));
|
||||
if (!dialog.runDialog(workingDirectory))
|
||||
return;
|
||||
commit = dialog.commit();
|
||||
}
|
||||
|
||||
if (m_gitClient->beginStashScope(workingDirectory, "Rebase-i"))
|
||||
m_gitClient->interactiveRebase(workingDirectory, commit, false);
|
||||
}
|
||||
|
||||
void GitPlugin::startChangeRelatedAction(const Id &id)
|
||||
|
@@ -95,6 +95,7 @@ public:
|
||||
const QStringList &args) override;
|
||||
void manageRemotes();
|
||||
void initRepository();
|
||||
void startRebaseFromCommit(const QString &workingDirectory, QString commit);
|
||||
|
||||
protected:
|
||||
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
|
||||
|
Reference in New Issue
Block a user