From 55b4fef0a09b73853d3869ee02aebabc1ad0f4e9 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Wed, 22 Jul 2026 16:13:52 +0200 Subject: [PATCH] Auto-generate .kateworkspace and .kateproject when opening a workspace If a workspace is detected (heuristic or submodule) but lacks these files, generate them automatically so Kate project detection works and workspace metadata is established for future operations. --- gitplusplus.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gitplusplus.cpp b/gitplusplus.cpp index 8f42d67..ac6e054 100644 --- a/gitplusplus.cpp +++ b/gitplusplus.cpp @@ -2282,6 +2282,27 @@ void GitPlusPlusView::detectWorkspace() m_workspaceRepos = workspaceRepoPaths(); } + // Auto-generate .kateworkspace if missing + wsFile = m_workspaceDir + QStringLiteral("/.kateworkspace"); + if (!QFileInfo::exists(wsFile)) { + QSettings ws(wsFile, QSettings::IniFormat); + ws.beginGroup(QStringLiteral("workspace")); + ws.setValue(QStringLiteral("source"), QStringLiteral(".")); + ws.endGroup(); + ws.sync(); + } + + // Auto-generate .kateproject if missing + QString kateProjectFile = m_workspaceDir + QStringLiteral("/.kateproject"); + if (!QFileInfo::exists(kateProjectFile)) { + QFile kp(kateProjectFile); + if (kp.open(QIODevice::WriteOnly | QIODevice::Text)) { + QString wsName = QFileInfo(m_workspaceDir).fileName(); + kp.write("{\n \"name\": \"" + wsName.toUtf8() + "\",\n \"files\": [ { \"git\": true } ]\n}\n"); + kp.close(); + } + } + // Populate repo combo m_repoCombo->blockSignals(true); m_repoCombo->clear();