| 487 | |
| 488 | |
| 489 | VcsJob* GitPlugin::revert(const QList<QUrl>& localLocations, IBasicVersionControl::RecursionMode recursion) |
| 490 | { |
| 491 | if(localLocations.isEmpty() ) |
| 492 | return makeVcsErrorJob(i18n("Could not revert changes"), this, OutputJob::Verbose); |
| 493 | |
| 494 | QDir repo = urlDir(repositoryRoot(localLocations.first())); |
| 495 | QString modified; |
| 496 | for (const auto& file: localLocations) { |
| 497 | if (hasModifications(repo, file)) { |
| 498 | modified.append(file.toDisplayString(QUrl::PreferLocalFile) + QLatin1String("<br/>")); |
| 499 | } |
| 500 | } |
| 501 | if (!modified.isEmpty()) { |
| 502 | auto res = KMessageBox::questionTwoActions(nullptr, |
| 503 | i18n("The following files have uncommitted changes, " |
| 504 | "which will be lost. Continue?") |
| 505 | + QLatin1String("<br/><br/>") + modified, |
| 506 | {}, KStandardGuiItem::discard(), KStandardGuiItem::cancel()); |
| 507 | if (res != KMessageBox::PrimaryAction) { |
| 508 | return makeVcsErrorJob(QString(), this, OutputJob::Silent); |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | DVcsJob* job = new GitJob(dotGitDirectory(localLocations.front()), this); |
| 513 | job->setType(VcsJob::Revert); |
| 514 | *job << "git" << "checkout" << "--"; |
| 515 | *job << (recursion == IBasicVersionControl::Recursive ? localLocations : preventRecursion(localLocations)); |
| 516 | |
| 517 | return job; |
| 518 | } |
| 519 | |
| 520 | |
| 521 | //TODO: git doesn't like empty messages, but "KDevelop didn't provide any message, it may be a bug" looks ugly... |
no test coverage detected