Kate: make it possible to force a mode for the "files" entry

By default, kate will try to autodetect whether the project is
a svn or git checkout or not.
In case this does not give a satisfying result, the user can now
set CMAKE_KATE_FILES_MODE to the mode he wants.
This commit is contained in:
Alexander Neundorf
2023-02-02 00:05:00 +01:00
committed by Brad King
parent 8a7aa2642b
commit 9a7612d2d0
4 changed files with 49 additions and 6 deletions

View File

@@ -220,14 +220,32 @@ void cmExtraKateGenerator::CreateDummyKateProjectFile(
std::string cmExtraKateGenerator::GenerateFilesString(
const cmLocalGenerator& lg) const
{
std::string s = cmStrCat(lg.GetSourceDirectory(), "/.git");
if (cmSystemTools::FileExists(s)) {
return "\"git\": 1 ";
const cmMakefile* mf = lg.GetMakefile();
std::string mode =
cmSystemTools::UpperCase(mf->GetSafeDefinition("CMAKE_KATE_FILES_MODE"));
static const std::string gitString = "\"git\": 1 ";
static const std::string svnString = "\"svn\": 1 ";
if (mode == "SVN") {
return svnString;
}
if (mode == "GIT") {
return gitString;
}
s = cmStrCat(lg.GetSourceDirectory(), "/.svn");
if (cmSystemTools::FileExists(s)) {
return "\"svn\": 1 ";
std::string s;
// check for the VCS files except when "forced" to "FILES" mode:
if (mode != "LIST") {
s = cmStrCat(lg.GetSourceDirectory(), "/.git");
if (cmSystemTools::FileExists(s)) {
return gitString;
}
s = cmStrCat(lg.GetSourceDirectory(), "/.svn");
if (cmSystemTools::FileExists(s)) {
return svnString;
}
}
s = cmStrCat(lg.GetSourceDirectory(), '/');