mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-17 13:37:18 +03:00
Rebase: Use original commit message as default message
Merge pull request #674 from Murmele/rebase
This commit is contained in:
commit
66bc256eed
@ -500,6 +500,7 @@ DetailView::DetailView(const git::Repository &repo, QWidget *parent)
|
||||
mDetail->setVisible(false);
|
||||
layout->addWidget(mDetail);
|
||||
|
||||
// Shown when a commit is selected
|
||||
mDetail->addWidget(new CommitDetail(this));
|
||||
|
||||
mAuthorLabel = new QLabel(this);
|
||||
@ -508,6 +509,7 @@ DetailView::DetailView(const git::Repository &repo, QWidget *parent)
|
||||
&DetailView::authorLinkActivated);
|
||||
updateAuthor();
|
||||
|
||||
// Shown when the working directory is dirty
|
||||
mCommitEditor = new CommitEditor(repo, this);
|
||||
|
||||
auto editorFrame = new QWidget(this);
|
||||
|
@ -1465,6 +1465,9 @@ void RepoView::rebaseConflict(const git::Rebase rebase) {
|
||||
if (mRebase) {
|
||||
mRebase->addEntry(tr("Please resolve conflicts before continue"),
|
||||
tr("Conflict"));
|
||||
mDetails->setCommitMessage(rebase.commitToRebase()
|
||||
.message(git::Commit::SubstituteEmoji)
|
||||
.trimmed());
|
||||
}
|
||||
refresh(false);
|
||||
}
|
||||
|
@ -75,6 +75,7 @@ class TestRebase : public QObject {
|
||||
private slots:
|
||||
void withoutConflicts();
|
||||
void conflictingRebase();
|
||||
void conflictingRebaseCustomMessage();
|
||||
void continueExternalStartedRebase(); // must have conflicts otherwise it is
|
||||
// not possible to continue
|
||||
void startRebaseContinueInCLI();
|
||||
@ -278,10 +279,6 @@ void TestRebase::conflictingRebase() {
|
||||
filewidgets.at(0)->stageStateChanged(filewidgets.at(0)->modelIndex(),
|
||||
git::Index::StagedState::Staged);
|
||||
|
||||
QTextEdit *editor = repoView->findChild<QTextEdit *>("MessageEditor");
|
||||
QVERIFY(editor);
|
||||
editor->setText("Test message");
|
||||
|
||||
refreshTriggered = 0;
|
||||
rebaseConflict = 0;
|
||||
repoView->continueRebase();
|
||||
@ -293,9 +290,8 @@ void TestRebase::conflictingRebase() {
|
||||
QList<Commit> parents = branch.annotatedCommit().commit().parents();
|
||||
QCOMPARE(parents.count(), 1);
|
||||
QCOMPARE(parents.at(0).id(), ac.commit().id());
|
||||
QCOMPARE(
|
||||
branch.annotatedCommit().commit().message(),
|
||||
"Test message"); // custom message was used instead of the original one
|
||||
QCOMPARE(branch.annotatedCommit().commit().message(),
|
||||
"File.txt changed by second branch"); // original message is shown
|
||||
|
||||
// Check that rebase was really finished
|
||||
QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
@ -313,6 +309,89 @@ void TestRebase::conflictingRebase() {
|
||||
QCOMPARE(rebaseConflict, 0);
|
||||
}
|
||||
|
||||
void TestRebase::conflictingRebaseCustomMessage() {
|
||||
INIT_REPO("rebaseConflicts.zip", true);
|
||||
|
||||
auto *detailview = repoView->findChild<DetailView *>();
|
||||
QVERIFY(detailview);
|
||||
auto *abortRebaseButton = detailview->findChild<QPushButton *>("AbortRebase");
|
||||
QVERIFY(abortRebaseButton);
|
||||
auto *continueRebaseButton =
|
||||
detailview->findChild<QPushButton *>("ContinueRebase");
|
||||
QVERIFY(continueRebaseButton);
|
||||
QCOMPARE(continueRebaseButton->isVisible(), false);
|
||||
QCOMPARE(abortRebaseButton->isVisible(), false);
|
||||
|
||||
const QString rebaseBranchName = "refs/heads/singleCommitConflict";
|
||||
|
||||
git::Reference branch = mRepo.lookupRef(rebaseBranchName);
|
||||
QVERIFY(branch.isValid());
|
||||
auto c = branch.annotatedCommit().commit();
|
||||
|
||||
// Checkout correct branch
|
||||
repoView->checkout(branch);
|
||||
|
||||
QTest::qWait(100);
|
||||
|
||||
// Rebase on main
|
||||
git::Reference mainBranch = mRepo.lookupRef(QString("refs/heads/main"));
|
||||
QVERIFY(mainBranch.isValid());
|
||||
auto ac = mainBranch.annotatedCommit();
|
||||
LogEntry *entry = repoView->addLogEntry("Rebase", "Rebase", nullptr);
|
||||
repoView->rebase(ac, entry);
|
||||
|
||||
QCOMPARE(mRepo.rebaseOngoing(), true);
|
||||
|
||||
// Check that buttons are visible
|
||||
QTest::qWait(100);
|
||||
|
||||
// Resolve conflicts
|
||||
diff = mRepo.status(mRepo.index(), nullptr, false);
|
||||
QCOMPARE(diff.count(), 1);
|
||||
QCOMPARE(diff.patch(0).isConflicted(), true);
|
||||
QFile f(mRepo.workdir().filePath(diff.patch(0).name()));
|
||||
QCOMPARE(f.open(QIODevice::WriteOnly), true);
|
||||
QVERIFY(f.write("Test123") !=
|
||||
-1); // just write something to resolve the conflict
|
||||
f.close();
|
||||
|
||||
QTest::qWait(100);
|
||||
|
||||
repoView->continueRebase(); // should fail
|
||||
|
||||
QTest::qWait(100); // Wait until refresh is done
|
||||
|
||||
// Staging the file
|
||||
auto filewidgets = repoView->findChildren<FileWidget *>();
|
||||
QCOMPARE(filewidgets.length(), 1);
|
||||
filewidgets.at(0)->stageStateChanged(filewidgets.at(0)->modelIndex(),
|
||||
git::Index::StagedState::Staged);
|
||||
|
||||
QTextEdit *editor = repoView->findChild<QTextEdit *>("MessageEditor");
|
||||
QVERIFY(editor);
|
||||
editor->setText("Test message"); // modify message
|
||||
|
||||
repoView->continueRebase();
|
||||
|
||||
// Check that branch is based on "main" now
|
||||
branch = mRepo.lookupRef(rebaseBranchName);
|
||||
QVERIFY(branch.isValid());
|
||||
QList<Commit> parents = branch.annotatedCommit().commit().parents();
|
||||
QCOMPARE(parents.count(), 1);
|
||||
QCOMPARE(parents.at(0).id(), ac.commit().id());
|
||||
QCOMPARE(branch.annotatedCommit().commit().message(),
|
||||
"Test message"); // Modified message is shown
|
||||
|
||||
// Check that rebase was really finished
|
||||
QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
|
||||
QTest::qWait(100); // Wait until refresh finished
|
||||
|
||||
// Check that buttons are visible
|
||||
QCOMPARE(continueRebaseButton->isVisible(), false);
|
||||
QCOMPARE(abortRebaseButton->isVisible(), false);
|
||||
}
|
||||
|
||||
void TestRebase::continueExternalStartedRebase() {
|
||||
// INIT_REPO("rebaseConflicts.zip", true);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user