forked from qt-creator/qt-creator
Git: Added submodule update
Change-Id: If8a4b0c572b0ca2d57f80f1304c7ebf141a40148 Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -873,6 +873,7 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
|
||||
outputWindow()->appendError(msg);
|
||||
return false;
|
||||
}
|
||||
promptSubmoduleUpdate(workingDirectory);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1710,6 +1711,27 @@ GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory,
|
||||
return Stashed;
|
||||
}
|
||||
|
||||
void GitClient::submoduleUpdate(const QString &workingDirectory)
|
||||
{
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("submodule") << QLatin1String("update");
|
||||
|
||||
VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true);
|
||||
connectRepositoryChanged(workingDirectory, cmd);
|
||||
}
|
||||
|
||||
void GitClient::promptSubmoduleUpdate(const QString &workingDirectory)
|
||||
{
|
||||
if (!QFile::exists(workingDirectory + QLatin1String("/.gitmodules")))
|
||||
return;
|
||||
|
||||
if (QMessageBox::question(Core::ICore::mainWindow(), tr("Submodules Found"),
|
||||
tr("Would you like to update submodules?"),
|
||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
submoduleUpdate(workingDirectory);
|
||||
}
|
||||
}
|
||||
|
||||
// Trim a git status file spec: "modified: foo .cpp" -> "modified: foo .cpp"
|
||||
static inline QString trimFileSpecification(QString fileSpec)
|
||||
{
|
||||
@@ -2312,7 +2334,12 @@ bool GitClient::synchronousPull(const QString &workingDirectory, bool rebase)
|
||||
abortCommand = QLatin1String("merge");
|
||||
}
|
||||
|
||||
return executeAndHandleConflicts(workingDirectory, arguments, abortCommand);
|
||||
bool ok = executeAndHandleConflicts(workingDirectory, arguments, abortCommand);
|
||||
|
||||
if (ok)
|
||||
promptSubmoduleUpdate(workingDirectory);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void GitClient::synchronousAbortCommand(const QString &workingDir, const QString &abortCommand)
|
||||
|
@@ -158,6 +158,8 @@ public:
|
||||
bool synchronousCheckout(const QString &workingDirectory, const QString &ref, QString *errorMessage);
|
||||
bool synchronousCheckout(const QString &workingDirectory, const QString &ref)
|
||||
{ return synchronousCheckout(workingDirectory, ref, 0); }
|
||||
void submoduleUpdate(const QString &workingDirectory);
|
||||
void promptSubmoduleUpdate(const QString &workingDirectory);
|
||||
|
||||
// Do a stash and return identier.
|
||||
enum { StashPromptDescription = 0x1, StashImmediateRestore = 0x2, StashIgnoreUnchanged = 0x4 };
|
||||
|
@@ -441,6 +441,11 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
tr("Change-related Actions..."), Core::Id("Git.ChangeRelatedActions"),
|
||||
globalcontext, true, SLOT(startChangeRelatedAction()));
|
||||
|
||||
m_submoduleUpdateAction =
|
||||
createRepositoryAction(localRepositoryMenu,
|
||||
tr("Update Submodules"), Core::Id("Git.SubmoduleUpdate"),
|
||||
globalcontext, true, SLOT(updateSubmodules())).first;
|
||||
|
||||
// --------------
|
||||
localRepositoryMenu->addSeparator(globalcontext);
|
||||
|
||||
@@ -1089,6 +1094,13 @@ void GitPlugin::cleanRepository(const QString &directory)
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void GitPlugin::updateSubmodules()
|
||||
{
|
||||
const VcsBase::VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_gitClient->submoduleUpdate(state.topLevel());
|
||||
}
|
||||
|
||||
// If the file is modified in an editor, make sure it is saved.
|
||||
static bool ensureFileSaved(const QString &fileName)
|
||||
{
|
||||
@@ -1224,13 +1236,14 @@ void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
||||
fileAction->setParameter(fileName);
|
||||
// If the current file looks like a patch, offer to apply
|
||||
m_applyCurrentFilePatchAction->setParameter(currentState().currentPatchFileDisplayName());
|
||||
|
||||
const QString projectName = currentState().currentProjectName();
|
||||
foreach (Utils::ParameterAction *projectAction, m_projectActions)
|
||||
projectAction->setParameter(projectName);
|
||||
|
||||
foreach (QAction *repositoryAction, m_repositoryActions)
|
||||
repositoryAction->setEnabled(repositoryEnabled);
|
||||
m_submoduleUpdateAction->setVisible(repositoryEnabled
|
||||
&& QFile::exists(currentState().topLevel() + QLatin1String("/.gitmodules")));
|
||||
updateRepositoryBrowserAction();
|
||||
}
|
||||
|
||||
|
@@ -123,6 +123,7 @@ private slots:
|
||||
void gitkForCurrentFolder();
|
||||
void cleanProject();
|
||||
void cleanRepository();
|
||||
void updateSubmodules();
|
||||
void applyCurrentFilePatch();
|
||||
void promptApplyPatch();
|
||||
void gitClientMemberFuncRepositoryAction();
|
||||
@@ -204,6 +205,7 @@ private:
|
||||
QAction *m_redoAction;
|
||||
QAction *m_menuAction;
|
||||
QAction *m_repositoryBrowserAction;
|
||||
QAction *m_submoduleUpdateAction;
|
||||
|
||||
QVector<Utils::ParameterAction *> m_fileActions;
|
||||
QVector<Utils::ParameterAction *> m_projectActions;
|
||||
|
Reference in New Issue
Block a user