Git: Fix pattern for commit hash matching

* Avoid matching mid-word.
* Avoid matching after "mode ".
* Change to raw string literals.

Fixes: QTCREATORBUG-24768
Fixes: QTCREATORBUG-28268
Change-Id: I68abbf3de7928c60e0fe2d944adedaa6db94b1a4
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2022-10-11 09:50:45 +03:00
committed by Orgad Shaneh
parent ae58d373b0
commit 7c623f99d8
2 changed files with 5 additions and 5 deletions

View File

@@ -29,7 +29,7 @@
#include <QTextCodec>
#include <QTextCursor>
#define CHANGE_PATTERN "[a-f0-9]{7,40}"
#define CHANGE_PATTERN "\\b[a-f0-9]{7,40}\\b"
using namespace Core;
using namespace Utils;

View File

@@ -21,10 +21,10 @@ namespace VcsBase {
VcsOutputLineParser::VcsOutputLineParser() :
m_regexp(
"(https?://\\S*)" // https://codereview.org/c/1234
"|(v[0-9]+\\.[0-9]+\\.[0-9]+[\\-A-Za-z0-9]*)" // v0.1.2-beta3
"|([0-9a-f]{6,}(?:\\.{2,3}[0-9a-f]{6,}" // 789acf or 123abc..456cde
"|\\^+|~\\d+)?)") // or 789acf^ or 123abc~99
R"((https?://\S*))" // https://codereview.org/c/1234
R"(|\b(v[0-9]+\.[0-9]+\.[0-9]+[\-A-Za-z0-9]*))" // v0.1.2-beta3
R"(|\b(?<!mode )([0-9a-f]{6,}(?:\.{2,3}[0-9a-f]{6,})" // 789acf or 123abc..456cde
R"(|\^+|~\d+)?)\b)") // or 789acf^ or 123abc~99
{
}