MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / commitChanges

Method commitChanges

3rdparty/unioncode-GitQlient/src/commits/WipWidget.cpp:49–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49void WipWidget::commitChanges()
50{
51 QString msg;
52 QStringList selFiles = getFiles();
53
54 if (!selFiles.isEmpty())
55 {
56 if (hasConflicts())
57 QMessageBox::warning(this, tr("Impossible to commit"),
58 tr("There are files with conflicts. Please, resolve "
59 "the conflicts first."));
60 else if (checkMsg(msg))
61 {
62 const auto revInfo = mCache->commitInfo(CommitInfo::ZERO_SHA);
63
64 QScopedPointer<GitWip> git(new GitWip(mGit, mCache));
65 git->updateWip();
66
67 if (const auto files = mCache->revisionFile(CommitInfo::ZERO_SHA, revInfo.firstParent()); files)
68 {
69 const auto lastShaBeforeCommit = mGit->getLastCommit().output.trimmed();
70 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
71 QScopedPointer<GitLocal> gitLocal(new GitLocal(mGit));
72 const auto ret = gitLocal->commitFiles(selFiles, files.value(), msg);
73 QApplication::restoreOverrideCursor();
74
75 if (ret.success)
76 {
77 // Adding new commit in the log
78 const auto currentSha = mGit->getLastCommit().output.trimmed();
79 QScopedPointer<GitConfig> gitConfig(new GitConfig(mGit));
80 auto committer = gitConfig->getLocalUserInfo();
81
82 if (committer.mUserEmail.isEmpty() || committer.mUserName.isEmpty())
83 committer = gitConfig->getGlobalUserInfo();
84
85 const auto message = msg.split("\n\n");
86
87 CommitInfo newCommit { currentSha,
88 { lastShaBeforeCommit },
89 std::chrono::seconds(QDateTime::currentDateTime().toSecsSinceEpoch()),
90 ui->leCommitTitle->text() };
91
92 newCommit.committer = QString("%1<%2>").arg(committer.mUserName, committer.mUserEmail);
93 newCommit.author = QString("%1<%2>").arg(committer.mUserName, committer.mUserEmail);
94 newCommit.longLog = ui->teDescription->toPlainText();
95
96 mCache->insertCommit(newCommit);
97 mCache->deleteReference(lastShaBeforeCommit, References::Type::LocalBranch, mGit->getCurrentBranch());
98 mCache->insertReference(currentSha, References::Type::LocalBranch, mGit->getCurrentBranch());
99
100 QScopedPointer<GitHistory> gitHistory(new GitHistory(mGit));
101 const auto ret = gitHistory->getDiffFiles(currentSha, lastShaBeforeCommit);
102
103 mCache->insertRevisionFiles(currentSha, lastShaBeforeCommit, RevisionFiles(ret.output));
104
105 prepareCache();
106 clearCache();

Callers

nothing calls this directly

Calls 15

getFilesFunction · 0.85
warningFunction · 0.85
commitInfoMethod · 0.80
revisionFileMethod · 0.80
firstParentMethod · 0.80
getLastCommitMethod · 0.80
commitFilesMethod · 0.80
getLocalUserInfoMethod · 0.80
getGlobalUserInfoMethod · 0.80
insertCommitMethod · 0.80
deleteReferenceMethod · 0.80
getCurrentBranchMethod · 0.80

Tested by

no test coverage detected