forked from qt-creator/qt-creator
Git: Provide a commit editor for files opened externally
Change-Id: I52fccf36cca032dda36102d4be2654eb7461de64 Reviewed-by: Eike Ziller <eike.ziller@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
a9d9d44494
commit
7bfaf7a946
9
src/plugins/git/Git.mimetypes.xml
Normal file
9
src/plugins/git/Git.mimetypes.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="text/vnd.qtcreator.git.commit">
|
||||
<sub-class-of type="text/plain"/>
|
||||
<comment>Git Commit File</comment>
|
||||
<glob pattern="COMMIT_MSG"/>
|
||||
<glob pattern="COMMIT_EDITMSG"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
@@ -62,4 +62,6 @@ include(gitorious/gitorious.pri)
|
||||
RESOURCES += \
|
||||
git.qrc
|
||||
|
||||
OTHER_FILES += Git.mimetypes.xml
|
||||
|
||||
include(gerrit/gerrit.pri)
|
||||
|
@@ -14,6 +14,7 @@ QtcPlugin {
|
||||
Depends { name: "Locator" }
|
||||
|
||||
files: [
|
||||
"Git.mimetypes.xml",
|
||||
"annotationhighlighter.cpp",
|
||||
"annotationhighlighter.h",
|
||||
"branchadddialog.cpp",
|
||||
|
@@ -2,5 +2,6 @@
|
||||
<qresource prefix="/git">
|
||||
<file>images/git.png</file>
|
||||
<file>images/gitorious.png</file>
|
||||
<file>Git.mimetypes.xml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -47,6 +47,9 @@ const char C_GIT_BLAME_EDITOR[] = "Git Annotation Editor";
|
||||
const char GIT_DIFF_EDITOR_ID[] = "Git Diff Editor";
|
||||
const char GIT_DIFF_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Diff Editor");
|
||||
const char C_GIT_DIFF_EDITOR[] = "Git Diff Editor";
|
||||
const char GIT_COMMIT_TEXT_EDITOR_ID[] = "Git Commit Editor";
|
||||
const char GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Commit Editor");
|
||||
const char C_GIT_COMMIT_TEXT_EDITOR[] = "Git Commit Editor";
|
||||
|
||||
const char C_GITSUBMITEDITOR[] = "Git Submit Editor";
|
||||
const char GITSUBMITEDITOR_ID[] = "Git Submit Editor";
|
||||
@@ -54,6 +57,7 @@ const char GITSUBMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Git Submit
|
||||
const char SUBMIT_CURRENT[] = "Git.SubmitCurrentLog";
|
||||
const char DIFF_SELECTED[] = "Git.DiffSelectedFilesInLog";
|
||||
const char SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.git.submit";
|
||||
const char C_GITEDITORID[] = "Git Editor";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace Git
|
||||
|
@@ -33,9 +33,12 @@
|
||||
#include "gitplugin.h"
|
||||
#include "gitclient.h"
|
||||
#include "gitsettings.h"
|
||||
#include "gitsubmiteditorwidget.h"
|
||||
#include "gitconstants.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
#include <texteditor/basetextdocument.h>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
#include <QRegExp>
|
||||
@@ -225,6 +228,13 @@ void GitEditor::revertChange()
|
||||
GitPlugin::instance()->gitClient()->synchronousRevert(workingDirectory, m_currentChange);
|
||||
}
|
||||
|
||||
void GitEditor::init()
|
||||
{
|
||||
VcsBase::VcsBaseEditorWidget::init();
|
||||
if (editor()->id() == Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID)
|
||||
new GitSubmitHighlighter(baseTextDocument().data());
|
||||
}
|
||||
|
||||
QString GitEditor::decorateVersion(const QString &revision) const
|
||||
{
|
||||
const QFileInfo fi(source());
|
||||
|
@@ -59,6 +59,7 @@ private slots:
|
||||
void revertChange();
|
||||
|
||||
private:
|
||||
void init();
|
||||
QSet<QString> annotationChanges() const;
|
||||
QString changeUnderCursor(const QTextCursor &) const;
|
||||
VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes, const QColor &bg) const;
|
||||
|
@@ -58,6 +58,7 @@
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/parameteraction.h>
|
||||
@@ -81,6 +82,7 @@
|
||||
#include <QScopedPointer>
|
||||
|
||||
static const unsigned minimumRequiredVersion = 0x010702;
|
||||
static const char RC_GIT_MIME_XML[] = ":/git/Git.mimetypes.xml";
|
||||
|
||||
static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
|
||||
{
|
||||
@@ -103,7 +105,12 @@ static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
|
||||
Git::Constants::GIT_DIFF_EDITOR_ID,
|
||||
Git::Constants::GIT_DIFF_EDITOR_DISPLAY_NAME,
|
||||
Git::Constants::C_GIT_DIFF_EDITOR,
|
||||
"text/x-patch"}
|
||||
"text/x-patch"},
|
||||
{ VcsBase::DiffOutput,
|
||||
Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID,
|
||||
Git::Constants::GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME,
|
||||
Git::Constants::C_GIT_COMMIT_TEXT_EDITOR,
|
||||
"text/vnd.qtcreator.git.commit"},
|
||||
};
|
||||
|
||||
// Utility to find a parameter set by type
|
||||
@@ -263,7 +270,6 @@ ActionCommandPair
|
||||
bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
m_settings.readSettings(Core::ICore::settings());
|
||||
|
||||
@@ -656,6 +662,9 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
command = Core::ActionManager::registerAction(m_redoAction, Core::Constants::REDO, submitContext);
|
||||
|
||||
|
||||
if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(RC_GIT_MIME_XML), errorMessage))
|
||||
return false;
|
||||
|
||||
/* "Gerrit" */
|
||||
m_gerritPlugin = new Gerrit::Internal::GerritPlugin(this);
|
||||
const bool ok = m_gerritPlugin->initialize(remoteRepositoryMenu);
|
||||
|
@@ -105,7 +105,7 @@ protected:
|
||||
void setLogEntryPattern(const QRegExp &pattern);
|
||||
|
||||
public:
|
||||
void init();
|
||||
virtual void init();
|
||||
|
||||
~VcsBaseEditorWidget();
|
||||
|
||||
|
Reference in New Issue
Block a user