diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-03-24 15:46:58 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-03-24 15:46:58 +0100 |
commit | 9b7274a0110712822ccbf93e1856b9a3d6e762c0 (patch) | |
tree | 41576ed019e7ebde930bed0ba0ba44b0bb91ade4 /src/plugins | |
parent | de6166fc91d57f20efa54602dda4380f0c2e18c8 (diff) | |
download | qt-creator-9b7274a0110712822ccbf93e1856b9a3d6e762c0.tar.gz |
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
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/git/gitsubmiteditor.cpp | 20 | ||||
-rw-r--r-- | src/plugins/git/gitsubmiteditor.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index 1f082e5188..4de97513fd 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -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(); diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h index a2c97e05e2..88f4dba8e1 100644 --- a/src/plugins/git/gitsubmiteditor.h +++ b/src/plugins/git/gitsubmiteditor.h @@ -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); |