forked from qt-creator/qt-creator
Remove comment lines from the git commit message (as git commit -F does not do that)
Reviewed-by: dt <qtc-committer@nokia.com> enter the commit message for your changes. Lines starting
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <vcsbase/submitfilemodel.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
@@ -121,6 +122,25 @@ void GitSubmitEditor::slotDiffSelected(const QStringList &files)
|
||||
emit diff(unstagedFiles, stagedFiles);
|
||||
}
|
||||
|
||||
QString GitSubmitEditor::fileContents() const
|
||||
{
|
||||
// We need to manually purge out comment lines starting with
|
||||
// hash '#' since git does not do that when using -F.
|
||||
const QChar newLine = QLatin1Char('\n');
|
||||
const QChar hash = QLatin1Char('#');
|
||||
QString message = VCSBase::VCSBaseSubmitEditor::fileContents();
|
||||
for (int pos = 0; pos < message.size(); ) {
|
||||
const int newLinePos = message.indexOf(newLine, pos);
|
||||
const int startOfNextLine = newLinePos == -1 ? message.size() : newLinePos + 1;
|
||||
if (message.at(pos) == hash) {
|
||||
message.remove(pos, startOfNextLine - pos);
|
||||
} else {
|
||||
pos = startOfNextLine;
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
GitSubmitEditorPanelData GitSubmitEditor::panelData() const
|
||||
{
|
||||
return const_cast<GitSubmitEditor*>(this)->submitEditorWidget()->panelData();
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
void setCommitData(const CommitData &);
|
||||
GitSubmitEditorPanelData panelData() const;
|
||||
|
||||
virtual QString fileContents() const;
|
||||
|
||||
signals:
|
||||
void diff(const QStringList &unstagedFiles, const QStringList &stagedFiles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user