| 23 | } |
| 24 | |
| 25 | void AmendWidget::configure(const QString &sha) |
| 26 | { |
| 27 | const auto commit = mCache->commitInfo(sha); |
| 28 | |
| 29 | ui->amendFrame->setVisible(true); |
| 30 | ui->warningButton->setVisible(true); |
| 31 | |
| 32 | if (commit.parentsCount() <= 0) |
| 33 | return; |
| 34 | |
| 35 | QScopedPointer<GitWip> git(new GitWip(mGit, mCache)); |
| 36 | git->updateWip(); |
| 37 | |
| 38 | const auto files = mCache->revisionFile(CommitInfo::ZERO_SHA, sha); |
| 39 | auto amendFiles = mCache->revisionFile(sha, commit.firstParent()); |
| 40 | |
| 41 | if (!amendFiles) |
| 42 | { |
| 43 | QScopedPointer<GitHistory> git(new GitHistory(mGit)); |
| 44 | const auto ret = git->getDiffFiles(mCurrentSha, commit.firstParent()); |
| 45 | |
| 46 | if (ret.success) |
| 47 | { |
| 48 | amendFiles = RevisionFiles(ret.output); |
| 49 | mCache->insertRevisionFiles(mCurrentSha, commit.firstParent(), amendFiles.value()); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | if (mCurrentSha != sha) |
| 54 | { |
| 55 | QLog_Info("UI", QString("Amending sha {%1}.").arg(mCurrentSha)); |
| 56 | |
| 57 | mCurrentSha = sha; |
| 58 | |
| 59 | const auto author = commit.author.split("<"); |
| 60 | ui->leAuthorName->setText(author.first()); |
| 61 | ui->leAuthorEmail->setText(author.last().mid(0, author.last().count() - 1)); |
| 62 | ui->teDescription->setPlainText(commit.longLog.trimmed()); |
| 63 | ui->leCommitTitle->setText(commit.shortLog); |
| 64 | |
| 65 | blockSignals(true); |
| 66 | ui->unstagedFilesList->clear(); |
| 67 | ui->stagedFilesList->clear(); |
| 68 | mInternalCache.clear(); |
| 69 | blockSignals(false); |
| 70 | |
| 71 | if (files) |
| 72 | insertFiles(files.value(), ui->unstagedFilesList); |
| 73 | |
| 74 | if (amendFiles) |
| 75 | insertFiles(amendFiles.value(), ui->stagedFilesList); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | QLog_Info("UI", QString("Updating files for SHA {%1}").arg(mCurrentSha)); |
| 80 | |
| 81 | prepareCache(); |
| 82 |
nothing calls this directly
no test coverage detected