Remove heuristic workspace detection
Workspace detection now relies solely on .kateworkspace marker files or .gitmodules. The heuristic (2+ sibling git repos) caused false positives when a standalone repo lived in a directory alongside other repos (e.g. ~/src/).
This commit is contained in:
parent
57895bcc48
commit
5cec45d755
|
|
@ -116,9 +116,7 @@ project using git submodules.
|
|||
A workspace is detected automatically when:
|
||||
|
||||
1. A directory contains a `.kateworkspace` file, **or**
|
||||
2. A directory contains two or more subdirectories that each have a `.git`
|
||||
folder (heuristic detection), **or**
|
||||
3. The project root contains a `.gitmodules` file (submodule monorepo)
|
||||
2. The project root contains a `.gitmodules` file (submodule monorepo)
|
||||
|
||||
The `.kateworkspace` file is an INI file with a `[workspace]` section:
|
||||
|
||||
|
|
|
|||
|
|
@ -2269,18 +2269,6 @@ void GitPlusPlusView::detectWorkspace()
|
|||
wsFile = dir.absoluteFilePath(QStringLiteral(".kateworkspace"));
|
||||
if (QFileInfo::exists(wsFile)) {
|
||||
m_workspaceDir = dir.absolutePath();
|
||||
} else {
|
||||
// Heuristic: parent dir has no .git but has 2+ child dirs with .git
|
||||
if (!QFileInfo::exists(parent.absoluteFilePath(QStringLiteral(".git")))) {
|
||||
int gitCount = 0;
|
||||
const auto entries = parent.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const auto &entry : entries) {
|
||||
if (QFileInfo::exists(parent.absoluteFilePath(entry + QStringLiteral("/.git"))))
|
||||
++gitCount;
|
||||
}
|
||||
if (gitCount >= 2)
|
||||
m_workspaceDir = parent.absolutePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2406,23 +2394,9 @@ void GitPlusPlusView::refreshWorkspaces()
|
|||
const auto entries = parentDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
|
||||
for (const auto &entry : entries) {
|
||||
QString sibPath = parentDir.absoluteFilePath(entry);
|
||||
// A workspace is a dir with .kateworkspace, or a dir with 2+ git repos inside
|
||||
bool isWs = QFileInfo::exists(sibPath + QStringLiteral("/.kateworkspace"));
|
||||
if (!isWs) {
|
||||
// Heuristic: contains 2+ git repos and no .git at top level
|
||||
if (!QFileInfo::exists(sibPath + QStringLiteral("/.git"))) {
|
||||
int cnt = 0;
|
||||
QDir sub(sibPath);
|
||||
const auto subEntries = sub.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const auto &se : subEntries) {
|
||||
if (QFileInfo::exists(sub.absoluteFilePath(se + QStringLiteral("/.git"))))
|
||||
++cnt;
|
||||
}
|
||||
isWs = (cnt >= 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWs) continue;
|
||||
// A workspace must have .kateworkspace
|
||||
if (!QFileInfo::exists(sibPath + QStringLiteral("/.kateworkspace")))
|
||||
continue;
|
||||
|
||||
// Get branch info from the first git repo inside
|
||||
QString branch;
|
||||
|
|
|
|||
Loading…
Reference in New Issue