| 894 | } |
| 895 | |
| 896 | VcsJob* GitPlugin::switchBranch(const QUrl &repository, const QString &branch) |
| 897 | { |
| 898 | QDir d=urlDir(repository); |
| 899 | |
| 900 | if(hasModifications(d)) { |
| 901 | auto answer = KMessageBox::questionTwoActionsCancel( |
| 902 | nullptr, i18n("There are pending changes, do you want to stash them first?"), {}, |
| 903 | KGuiItem(i18nc("@action:button", "Stash"), QStringLiteral("vcs-stash")), |
| 904 | KGuiItem(i18nc("@action:button", "Keep"), QStringLiteral("dialog-cancel"))); |
| 905 | if (answer == KMessageBox::PrimaryAction) { |
| 906 | QScopedPointer<VcsJob> stash(gitStash(d, QStringList(), KDevelop::OutputJob::Verbose)); |
| 907 | stash->exec(); |
| 908 | } else if (answer == KMessageBox::Cancel) { |
| 909 | return nullptr; |
| 910 | } |
| 911 | } |
| 912 | |
| 913 | auto* job = new GitJob(d, this); |
| 914 | *job << "git" << "checkout" << branch; |
| 915 | return job; |
| 916 | } |
| 917 | |
| 918 | VcsJob* GitPlugin::branch(const QUrl& repository, const KDevelop::VcsRevision& rev, const QString& branchName) |
| 919 | { |