Git: show commit given as command line parameter in diff editor

ex: qtcreator -client -git-show d3eb585db9 from qt-creator source dir.

Change-Id: Ice62f062d431d2ab74e3d6832dfc8b0b555dfa19
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Nikita Baryshnikov
2018-02-22 18:31:14 +03:00
parent f044e69f67
commit e3918b563f
3 changed files with 27 additions and 1 deletions

View File

@@ -15,6 +15,13 @@
\"Category\" : \"Version Control\", \"Category\" : \"Version Control\",
\"Description\" : \"Git integration.\", \"Description\" : \"Git integration.\",
\"Url\" : \"http://www.qt.io\", \"Url\" : \"http://www.qt.io\",
\"Arguments\" : [
{
\"Name\" : \"-git-show\",
\"Parameter\" : \"git commit hash\",
\"Description\" : \"Show given commit hash\"
}
],
$$dependencyList, $$dependencyList,
\"Mimetypes\" : [ \"Mimetypes\" : [

View File

@@ -289,7 +289,6 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &t
bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{ {
Q_UNUSED(arguments)
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
Context context(Constants::GIT_CONTEXT); Context context(Constants::GIT_CONTEXT);
@@ -668,6 +667,12 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_gerritPlugin->updateActions(currentState()); m_gerritPlugin->updateActions(currentState());
m_gerritPlugin->addToLocator(m_commandLocator); m_gerritPlugin->addToLocator(m_commandLocator);
auto cmdContext = new QObject(this);
connect(Core::ICore::instance(), &Core::ICore::coreOpened, cmdContext, [this, cmdContext, arguments] {
remoteCommand(arguments, QDir::currentPath(), {});
cmdContext->deleteLater();
});
return ok; return ok;
} }
@@ -1418,6 +1423,17 @@ void GitPlugin::updateBranches(const QString &repository)
m_branchDialog->refreshIfSame(repository); m_branchDialog->refreshIfSame(repository);
} }
QObject *GitPlugin::remoteCommand(const QStringList &options, const QString &workingDirectory,
const QStringList &)
{
if (!m_gitClient || options.size() < 2)
return nullptr;
if (options.first() == "-git-show")
m_gitClient->show(workingDirectory, options.at(1));
return nullptr;
}
void GitPlugin::updateRepositoryBrowserAction() void GitPlugin::updateRepositoryBrowserAction()
{ {
const bool repositoryEnabled = currentState().hasTopLevel(); const bool repositoryEnabled = currentState().hasTopLevel();

View File

@@ -89,6 +89,9 @@ public:
void startCommit(CommitType commitType = SimpleCommit); void startCommit(CommitType commitType = SimpleCommit);
void updateBranches(const QString &repository); void updateBranches(const QString &repository);
QObject *remoteCommand(const QStringList &options, const QString &workingDirectory,
const QStringList &args) override;
protected: protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState) override; void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose() override; bool submitEditorAboutToClose() override;