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

Method remove

plugins/git/gitplugin.cpp:619–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

617}
618
619VcsJob* GitPlugin::remove(const QList<QUrl>& files)
620{
621 if (files.isEmpty())
622 return makeVcsErrorJob(i18n("No files to remove"), this);
623 QDir dotGitDir = dotGitDirectory(files.front());
624
625
626 QList<QUrl> files_(files);
627
628 QMutableListIterator<QUrl> i(files_);
629 while (i.hasNext()) {
630 QUrl file = i.next();
631 QFileInfo fileInfo(file.toLocalFile());
632
633 const QStringList otherStr = getLsFiles(dotGitDir, QStringList{QStringLiteral("--others"), QStringLiteral("--"), file.toLocalFile()}, KDevelop::OutputJob::Silent);
634 if(!otherStr.isEmpty()) {
635 //remove files not under version control
636 QList<QUrl> otherFiles;
637 otherFiles.reserve(otherStr.size());
638 for (const QString& f : otherStr) {
639 otherFiles << QUrl::fromLocalFile(dotGitDir.path() + QLatin1Char('/') + f);
640 }
641 if (fileInfo.isFile()) {
642 //if it's an unversioned file we are done, don't use git rm on it
643 i.remove();
644 }
645
646 auto deleteJob = KIO::del(otherFiles);
647 deleteJob->exec();
648 qCDebug(PLUGIN_GIT) << "other files" << otherFiles;
649 }
650
651 if (fileInfo.isDir()) {
652 if (isEmptyDirStructure(QDir(file.toLocalFile()))) {
653 //remove empty folders, git doesn't do that
654 auto deleteJob = KIO::del(file);
655 deleteJob->exec();
656 qCDebug(PLUGIN_GIT) << "empty folder, removing" << file;
657 //we already deleted it, don't use git rm on it
658 i.remove();
659 }
660 }
661 }
662
663 if (files_.isEmpty()) return nullptr;
664
665 DVcsJob* job = new GitJob(dotGitDir, this);
666 job->setType(VcsJob::Remove);
667 // git refuses to delete files with local modifications
668 // use --force to overcome this
669 *job << "git" << "rm" << "-r" << "--force";
670 *job << "--" << files_;
671 return job;
672}
673
674VcsJob* GitPlugin::log(const QUrl& localLocation,
675 const KDevelop::VcsRevision& src, const KDevelop::VcsRevision& dst)

Callers 15

toHtmlMethod · 0.45
setChecksMethod · 0.45
updateCommandLineMethod · 0.45
cmdToSendMethod · 0.45
testRemoveEmptyFolderMethod · 0.45
viewDestroyedMethod · 0.45
updateHistoryMethod · 0.45

Calls 12

dotGitDirectoryFunction · 0.85
isEmptyDirStructureFunction · 0.85
toLocalFileMethod · 0.80
execMethod · 0.80
QDirClass · 0.70
isEmptyMethod · 0.45
hasNextMethod · 0.45
nextMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
pathMethod · 0.45
setTypeMethod · 0.45

Tested by 15

testRemoveEmptyFolderMethod · 0.36
createFileFunction · 0.36
testTemplateMethod · 0.36
testReplaceMethod · 0.36
mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36
mainFunction · 0.36