MCPcopy Create free account
hub / github.com/KDE/kdevelop / isValidDirectory

Method isValidDirectory

plugins/git/gitplugin.cpp:300–322  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300bool GitPlugin::isValidDirectory(const QUrl & dirPath)
301{
302 QDir dir = dotGitDirectory(dirPath, true);
303 QFile dotGitPotentialFile(dir.filePath(QStringLiteral(".git")));
304 // if .git is a file, we may be in a git worktree
305 QFileInfo dotGitPotentialFileInfo(dotGitPotentialFile);
306 if (!dotGitPotentialFileInfo.isDir() && dotGitPotentialFile.exists()) {
307 QString gitWorktreeFileContent;
308 if (dotGitPotentialFile.open(QFile::ReadOnly)) {
309 // the content should be gitdir: /path/to/the/.git/worktree
310 gitWorktreeFileContent = QString::fromUtf8(dotGitPotentialFile.readAll());
311 dotGitPotentialFile.close();
312 } else {
313 return false;
314 }
315 const auto items = gitWorktreeFileContent.split(QLatin1Char(' '));
316 if (items.size() == 2 && items.at(0) == QLatin1String("gitdir:")) {
317 qCDebug(PLUGIN_GIT) << "we are in a git worktree" << items.at(1);
318 return true;
319 }
320 }
321 return dir.exists(QStringLiteral(".git/HEAD"));
322}
323
324bool GitPlugin::isValidRemoteRepositoryUrl(const QUrl& remoteLocation)
325{

Callers 1

repoInitMethod · 0.45

Calls 8

dotGitDirectoryFunction · 0.85
existsMethod · 0.80
filePathMethod · 0.45
openMethod · 0.45
closeMethod · 0.45
splitMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by 1

repoInitMethod · 0.36