aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorNikita Baryshnikov <[email protected]>2018-02-22 18:31:14 +0300
committerNikita Baryshnikov <[email protected]>2018-03-16 09:45:45 +0000
commite3918b563f87db838ca279ad63a460d992fc03b4 (patch)
treed7abe38e2af914391b6ec86d633fc5a2c3911e74 /src/plugins
parentf044e69f675f8dc12efee4a9715a3217ebd47a02 (diff)
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 <[email protected]> Reviewed-by: Orgad Shaneh <[email protected]> Reviewed-by: AndrĂ© Hartmann <[email protected]>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/git/Git.json.in7
-rw-r--r--src/plugins/git/gitplugin.cpp18
-rw-r--r--src/plugins/git/gitplugin.h3
3 files changed, 27 insertions, 1 deletions
diff --git a/src/plugins/git/Git.json.in b/src/plugins/git/Git.json.in
index 6c129f9b4ab..244ed2f8435 100644
--- a/src/plugins/git/Git.json.in
+++ b/src/plugins/git/Git.json.in
@@ -15,6 +15,13 @@
\"Category\" : \"Version Control\",
\"Description\" : \"Git integration.\",
\"Url\" : \"http://www.qt.io\",
+ \"Arguments\" : [
+ {
+ \"Name\" : \"-git-show\",
+ \"Parameter\" : \"git commit hash\",
+ \"Description\" : \"Show given commit hash\"
+ }
+ ],
$$dependencyList,
\"Mimetypes\" : [
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index ddab8cd2fed..4657b68ac24 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -289,7 +289,6 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &t
bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
- Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
Context context(Constants::GIT_CONTEXT);
@@ -668,6 +667,12 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
m_gerritPlugin->updateActions(currentState());
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;
}
@@ -1418,6 +1423,17 @@ void GitPlugin::updateBranches(const QString &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()
{
const bool repositoryEnabled = currentState().hasTopLevel();
diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h
index aa157c4c87b..f382e3a0abc 100644
--- a/src/plugins/git/gitplugin.h
+++ b/src/plugins/git/gitplugin.h
@@ -89,6 +89,9 @@ public:
void startCommit(CommitType commitType = SimpleCommit);
void updateBranches(const QString &repository);
+ QObject *remoteCommand(const QStringList &options, const QString &workingDirectory,
+ const QStringList &args) override;
+
protected:
void updateActions(VcsBase::VcsBasePlugin::ActionState) override;
bool submitEditorAboutToClose() override;