forked from qt-creator/qt-creator
Optionally shorten git blame output by removing date+line number.
This commit is contained in:
@@ -493,7 +493,7 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QTC_ASSERT(editor, /**/);
|
QTC_ASSERT(editor, /**/);
|
||||||
connect(command, SIGNAL(outputData(QByteArray)), editor, SLOT(setPlainTextData(QByteArray)));
|
connect(command, SIGNAL(outputData(QByteArray)), editor, SLOT(setPlainTextDataFiltered(QByteArray)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outputWindow)
|
if (outputWindow)
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
#include "gitconstants.h"
|
#include "gitconstants.h"
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
|
#include <QtCore/QTextCodec>
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -141,5 +142,47 @@ QString GitEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock) cons
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove the date specification from annotation, which is tabular:
|
||||||
|
\code
|
||||||
|
8ca887aa (author YYYY-MM-DD HH:MM:SS <offset> <line>)<content>
|
||||||
|
\endcode */
|
||||||
|
|
||||||
|
static void removeAnnotationDate(QString *s)
|
||||||
|
{
|
||||||
|
if (s->isEmpty())
|
||||||
|
return;
|
||||||
|
// Get position of date (including blank) and the ')'
|
||||||
|
const QRegExp isoDatePattern(QLatin1String(" \\d{4}-\\d{2}-\\d{2}"));
|
||||||
|
Q_ASSERT(isoDatePattern.isValid());
|
||||||
|
const int datePos = s->indexOf(isoDatePattern);
|
||||||
|
const int parenPos = datePos == -1 ? -1 : s->indexOf(QLatin1Char(')'));
|
||||||
|
if (parenPos == -1)
|
||||||
|
return;
|
||||||
|
// In all lines, remove the bit from datePos .. parenPos;
|
||||||
|
const int dateLength = parenPos - datePos;
|
||||||
|
const QChar newLine = QLatin1Char('\n');
|
||||||
|
for (int pos = 0; pos < s->size(); ) {
|
||||||
|
if (pos + parenPos >s->size()) // Should not happen
|
||||||
|
break;
|
||||||
|
s->remove(pos + datePos, dateLength);
|
||||||
|
const int nextLinePos = s->indexOf(newLine, pos + datePos);
|
||||||
|
pos = nextLinePos == -1 ? s->size() : nextLinePos + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitEditor::setPlainTextDataFiltered(const QByteArray &a)
|
||||||
|
{
|
||||||
|
// If desired, filter out the date from annotation
|
||||||
|
const bool omitAnnotationDate = contentType() == VCSBase::AnnotateOutput
|
||||||
|
&& GitPlugin::instance()->settings().omitAnnotationDate;
|
||||||
|
if (omitAnnotationDate) {
|
||||||
|
QString text = codec()->toUnicode(a);
|
||||||
|
removeAnnotationDate(&text);
|
||||||
|
setPlainText(text);
|
||||||
|
} else {
|
||||||
|
setPlainTextData(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
@@ -47,6 +47,9 @@ public:
|
|||||||
explicit GitEditor(const VCSBase::VCSBaseEditorParameters *type,
|
explicit GitEditor(const VCSBase::VCSBaseEditorParameters *type,
|
||||||
QWidget *parent);
|
QWidget *parent);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setPlainTextDataFiltered(const QByteArray &a);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual QSet<QString> annotationChanges() const;
|
virtual QSet<QString> annotationChanges() const;
|
||||||
virtual QString changeUnderCursor(const QTextCursor &) const;
|
virtual QString changeUnderCursor(const QTextCursor &) const;
|
||||||
|
@@ -42,6 +42,7 @@ static const char *pathKeyC = "Path";
|
|||||||
static const char *logCountKeyC = "LogCount";
|
static const char *logCountKeyC = "LogCount";
|
||||||
static const char *timeoutKeyC = "TimeOut";
|
static const char *timeoutKeyC = "TimeOut";
|
||||||
static const char *promptToSubmitKeyC = "PromptForSubmit";
|
static const char *promptToSubmitKeyC = "PromptForSubmit";
|
||||||
|
static const char *omitAnnotationDateKeyC = "OmitAnnotationDate";
|
||||||
|
|
||||||
enum { defaultLogCount = 10 , defaultTimeOut = 30};
|
enum { defaultLogCount = 10 , defaultTimeOut = 30};
|
||||||
|
|
||||||
@@ -52,7 +53,8 @@ GitSettings::GitSettings() :
|
|||||||
adoptPath(false),
|
adoptPath(false),
|
||||||
logCount(defaultLogCount),
|
logCount(defaultLogCount),
|
||||||
timeout(defaultTimeOut),
|
timeout(defaultTimeOut),
|
||||||
promptToSubmit(true)
|
promptToSubmit(true),
|
||||||
|
omitAnnotationDate(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ void GitSettings::fromSettings(QSettings *settings)
|
|||||||
logCount = settings->value(QLatin1String(logCountKeyC), defaultLogCount).toInt();
|
logCount = settings->value(QLatin1String(logCountKeyC), defaultLogCount).toInt();
|
||||||
timeout = settings->value(QLatin1String(timeoutKeyC), defaultTimeOut).toInt();
|
timeout = settings->value(QLatin1String(timeoutKeyC), defaultTimeOut).toInt();
|
||||||
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
||||||
|
omitAnnotationDate = settings->value(QLatin1String(omitAnnotationDateKeyC), false).toBool();
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,13 +78,15 @@ void GitSettings::toSettings(QSettings *settings) const
|
|||||||
settings->setValue(QLatin1String(logCountKeyC), logCount);
|
settings->setValue(QLatin1String(logCountKeyC), logCount);
|
||||||
settings->setValue(QLatin1String(timeoutKeyC), timeout);
|
settings->setValue(QLatin1String(timeoutKeyC), timeout);
|
||||||
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
||||||
|
settings->setValue(QLatin1String(omitAnnotationDateKeyC), omitAnnotationDate);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitSettings::equals(const GitSettings &s) const
|
bool GitSettings::equals(const GitSettings &s) const
|
||||||
{
|
{
|
||||||
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount
|
return adoptPath == s.adoptPath && path == s.path && logCount == s.logCount
|
||||||
&& timeout == s.timeout && promptToSubmit == s.promptToSubmit;
|
&& timeout == s.timeout && promptToSubmit == s.promptToSubmit
|
||||||
|
&& omitAnnotationDate == s.omitAnnotationDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||||
|
@@ -56,6 +56,7 @@ struct GitSettings
|
|||||||
int logCount;
|
int logCount;
|
||||||
int timeout;
|
int timeout;
|
||||||
bool promptToSubmit;
|
bool promptToSubmit;
|
||||||
|
bool omitAnnotationDate;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline bool operator==(const GitSettings &p1, const GitSettings &p2)
|
inline bool operator==(const GitSettings &p1, const GitSettings &p2)
|
||||||
|
@@ -54,7 +54,8 @@ GitSettings SettingsPageWidget::settings() const
|
|||||||
rc.adoptPath = m_ui.environmentGroupBox->isChecked() && !rc.path.isEmpty();
|
rc.adoptPath = m_ui.environmentGroupBox->isChecked() && !rc.path.isEmpty();
|
||||||
rc.logCount = m_ui.logCountSpinBox->value();
|
rc.logCount = m_ui.logCountSpinBox->value();
|
||||||
rc.timeout = m_ui.timeoutSpinBox->value();
|
rc.timeout = m_ui.timeoutSpinBox->value();
|
||||||
rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
|
rc.promptToSubmit = m_ui.promptToSubmitCheckBox->isChecked();
|
||||||
|
rc.omitAnnotationDate = m_ui.omitAnnotationDataCheckBox->isChecked();
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ void SettingsPageWidget::setSettings(const GitSettings &s)
|
|||||||
m_ui.logCountSpinBox->setValue(s.logCount);
|
m_ui.logCountSpinBox->setValue(s.logCount);
|
||||||
m_ui.timeoutSpinBox->setValue(s.timeout);
|
m_ui.timeoutSpinBox->setValue(s.timeout);
|
||||||
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
|
m_ui.promptToSubmitCheckBox->setChecked(s.promptToSubmit);
|
||||||
|
m_ui.omitAnnotationDataCheckBox->setChecked(s.omitAnnotationDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsPageWidget::setSystemPath()
|
void SettingsPageWidget::setSystemPath()
|
||||||
|
@@ -111,6 +111,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="omitAnnotationDataCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Omit date from annotation output</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Reference in New Issue
Block a user