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.
This commit is contained in:
parent
029b1885a6
commit
55b4fef0a0
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue