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:
Friedemann Kleint
2009-03-24 15:46:58 +01:00
parent de6166fc91
commit 9b7274a011
2 changed files with 22 additions and 0 deletions

View File

@@ -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();