diff options
| author | Christoph Berg <myon@debian.org> | 2026-04-07 19:02:45 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-04-07 19:02:45 +0200 |
| commit | f647d78463c1250ce9c99af664615fafccf5e959 (patch) | |
| tree | 5b00428cef68aef1c9d407e2d4535687422419b6 /revision_utils.cpp | |
| parent | 0a13f1fdb9928b6d012569dd65f7f6ef18fac2f8 (diff) | |
New upstream version 3.0.0upstream/3.0.0
Diffstat (limited to 'revision_utils.cpp')
| -rw-r--r--[-rwxr-xr-x] | revision_utils.cpp | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/revision_utils.cpp b/revision_utils.cpp index 1296691b..2406288e 100755..100644 --- a/revision_utils.cpp +++ b/revision_utils.cpp @@ -1,85 +1,85 @@ -#include "revision_utils.hpp"
-
-#include <cstring>
-
-#include <QCoreApplication>
-#include <QRegularExpression>
-
-#include "scs_version.h"
-
-namespace
-{
- QString revision_extract_number (QString const& s)
- {
- QString revision;
-
- // try and match a number (hexadecimal allowed)
- QRegularExpression re {R"(^[$:]\w+: (r?[\da-f]+[^$]*)\$$)"};
- auto match = re.match (s);
- if (match.hasMatch ())
- {
- revision = match.captured (1);
- }
- return revision;
- }
-}
-
-QString revision (QString const& scs_rev_string)
-{
- return "250915";
- QString result;
- auto revision_from_scs = revision_extract_number (scs_rev_string);
-
-#if defined (CMAKE_BUILD)
- QString scs_info {":Rev: " SCS_VERSION_STR " $"};
-
- auto revision_from_scs_info = revision_extract_number (scs_info);
- if (!revision_from_scs_info.isEmpty ())
- {
- // we managed to get the revision number from svn info etc.
- result = revision_from_scs_info;
- }
- else if (!revision_from_scs.isEmpty ())
- {
- // fall back to revision passed in if any
- result = revision_from_scs;
- }
- else
- {
- // match anything
- QRegularExpression re {R"(^[$:]\w+: ([^$]*)\$$)"};
- auto match = re.match (scs_info);
- if (match.hasMatch ())
- {
- result = match.captured (1);
- }
- }
-#else
- if (!revision_from_scs.isEmpty ())
- {
- // not CMake build so all we have is revision passed
- result = revision_from_scs;
- }
-#endif
- return result.trimmed ();
-}
-
-QString version (bool include_patch)
-{
-#if defined (CMAKE_BUILD)
- QString v {TO_STRING__ (PROJECT_VERSION_MAJOR) "." TO_STRING__ (PROJECT_VERSION_MINOR)};
- if (include_patch)
- {
- v += "." TO_STRING__ (PROJECT_VERSION_PATCH) + QString {BUILD_TYPE_REVISION};
- }
-#else
- QString v {"Not for Release"};
-#endif
- return v;
-}
-
-QString program_title (QString const& revision)
-{
- QString id {QCoreApplication::applicationName () + " v" + QCoreApplication::applicationVersion ()};
- return id + " " + revision;
-}
+#include "revision_utils.hpp" + +#include <cstring> + +#include <QCoreApplication> +#include <QRegularExpression> + +#include "scs_version.h" + +namespace +{ + QString revision_extract_number (QString const& s) + { + QString revision; + + // try and match a number (hexadecimal allowed) + QRegularExpression re {R"(^[$:]\w+: (r?[\da-f]+[^$]*)\$$)"}; + auto match = re.match (s); + if (match.hasMatch ()) + { + revision = match.captured (1); + } + return revision; + } +} + +QString revision (QString const& scs_rev_string) +{ + // return "251203"; + QString result; + auto revision_from_scs = revision_extract_number (scs_rev_string); + +#if defined (CMAKE_BUILD) + QString scs_info {":Rev: " SCS_VERSION_STR " $"}; + + auto revision_from_scs_info = revision_extract_number (scs_info); + if (!revision_from_scs_info.isEmpty ()) + { + // we managed to get the revision number from svn info etc. + result = revision_from_scs_info; + } + else if (!revision_from_scs.isEmpty ()) + { + // fall back to revision passed in if any + result = revision_from_scs; + } + else + { + // match anything + QRegularExpression re {R"(^[$:]\w+: ([^$]*)\$$)"}; + auto match = re.match (scs_info); + if (match.hasMatch ()) + { + result = match.captured (1); + } + } +#else + if (!revision_from_scs.isEmpty ()) + { + // not CMake build so all we have is revision passed + result = revision_from_scs; + } +#endif + return result.trimmed (); +} + +QString version (bool include_patch) +{ +#if defined (CMAKE_BUILD) + QString v {TO_STRING__ (PROJECT_VERSION_MAJOR) "." TO_STRING__ (PROJECT_VERSION_MINOR)}; + if (include_patch) + { + v += "." TO_STRING__ (PROJECT_VERSION_PATCH) + QString {BUILD_TYPE_REVISION}; + } +#else + QString v {"Not for Release"}; +#endif + return v; +} + +QString program_title (QString const& revision) +{ + QString id {QCoreApplication::applicationName () + " v" + QCoreApplication::applicationVersion ()}; + return id + " " + revision ; +} |
