File 0001-Provide-git-configuration-entries-as-Qt-creator-vari.patch of Package qt-creator

From 7051aa4daa10dd1e1936920f95b1aad5b0e1d65e Mon Sep 17 00:00:00 2001
From: Ralf Habacker <ralf.habacker@freenet.de>
Date: Wed, 27 Mar 2024 17:02:31 +0100
Subject: [PATCH] Provide git configuration entries as Qt creator variables
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

With this commit, variables from the Git repository configuration
of the current project are provided as Qt Creator variables.
Corresponding variable names must be specified in the form
'%{Git:Config:<key>}'. The user name known to git can, for
example, be queried with '%{Git:Config:user.name}'

Change-Id: I5ecb2589a9f8662950493e62f64248f9d853699f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
---
 src/plugins/git/gitplugin.cpp                   | 8 ++++++++
 tests/licenseheader/test-git-config-variables.h | 2 ++
 2 files changed, 10 insertions(+)
 create mode 100644 tests/licenseheader/test-git-config-variables.h

diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 3b557b1d580..fe0a9d9c917 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -48,6 +48,7 @@
 #include <utils/commandline.h>
 #include <utils/fileutils.h>
 #include <utils/infobar.h>
+#include <utils/macroexpander.h>
 #include <utils/pathchooser.h>
 #include <utils/qtcassert.h>
 #include <utils/stringutils.h>
@@ -554,6 +555,13 @@ GitPluginPrivate::GitPluginPrivate()
 {
     dd = this;
 
+    Utils::globalMacroExpander()->registerPrefix(
+        "Git:Config",
+        Tr::tr("Access git config variables."),
+        [this](const QString &value) {
+            return gitClient().readConfigValue(currentState().topLevel(), value);
+        },
+        true);
     setTopicFileTracker([](const FilePath &repository) {
         const FilePath gitDir = gitClient().findGitDirForRepository(repository);
         return gitDir.isEmpty() ? FilePath() : gitDir / "HEAD";
diff --git a/tests/licenseheader/test-git-config-variables.h b/tests/licenseheader/test-git-config-variables.h
new file mode 100644
index 00000000000..904e7e29953
--- /dev/null
+++ b/tests/licenseheader/test-git-config-variables.h
@@ -0,0 +1,2 @@
+// %{Git:Config:user.name}
+// %{Git:Config:user.email}
-- 
2.48.1

openSUSE Build Service is sponsored by