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

Method switchBranch

plugins/git/gitplugin.cpp:896–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

894}
895
896VcsJob* 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
918VcsJob* GitPlugin::branch(const QUrl& repository, const KDevelop::VcsRevision& rev, const QString& branchName)
919{

Callers 6

setCurrentBranchMethod · 0.80
checkoutBranchMethod · 0.80
timeSwitchingBranchFunction · 0.80
testBranchMethod · 0.80
testMergeMethod · 0.80
testStashMethod · 0.80

Calls 3

QStringListClass · 0.85
execMethod · 0.80
urlDirFunction · 0.70

Tested by 4

timeSwitchingBranchFunction · 0.64
testBranchMethod · 0.64
testMergeMethod · 0.64
testStashMethod · 0.64