mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-10-06 06:57:09 +03:00
WIP
This commit is contained in:
parent
58be827b3a
commit
eac0d96ff1
@ -414,7 +414,10 @@ public:
|
||||
QString msg = commit.message(git::Commit::SubstituteEmoji).trimmed();
|
||||
mMessage->setPlainText(msg);
|
||||
|
||||
int size = kSize * window()->windowHandle()->devicePixelRatio();
|
||||
auto w = window();
|
||||
auto w_handler = w->windowHandle();
|
||||
|
||||
int size = kSize * w_handler->devicePixelRatio();
|
||||
QByteArray email = commit.author().email().trimmed().toLower().toUtf8();
|
||||
QByteArray hash = QCryptographicHash::hash(email, QCryptographicHash::Md5);
|
||||
|
||||
|
@ -439,7 +439,7 @@ void RepoView::diffSelected(const git::Diff diff, const QString &file,
|
||||
bool spontaneous) {
|
||||
git::Diff diff2 = diff;
|
||||
mHistory->update(diff.isValid() ? location() : Location(),
|
||||
spontaneous); // why this changes diff?
|
||||
spontaneous); // TODO: why this changes diff?
|
||||
mDetails->setDiff(diff2, file, mPathspec->pathspec());
|
||||
}
|
||||
|
||||
|
232
test/rebase.cpp
232
test/rebase.cpp
@ -63,147 +63,147 @@ private:
|
||||
//###################################################################################################
|
||||
|
||||
void TestRebase::withoutConflicts() {
|
||||
INIT_REPO("rebaseConflicts.zip", false);
|
||||
INIT_REPO("rebaseConflicts.zip", false);
|
||||
|
||||
int rebaseFinished = 0;
|
||||
int rebaseAboutToRebase = 0;
|
||||
int rebaseCommitSuccess = 0;
|
||||
int rebaseConflict = 0;
|
||||
// int rebaseFinished = 0;
|
||||
// int rebaseAboutToRebase = 0;
|
||||
// int rebaseCommitSuccess = 0;
|
||||
// int rebaseConflict = 0;
|
||||
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseInitError, [=](){QVERIFY(false);}); // Should not be called
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseAboutToRebase, [=, &rebaseAboutToRebase](const Rebase rebase, const Commit before, int count, LogEntry* parent){
|
||||
QVERIFY(rebase.isValid());
|
||||
QCOMPARE(count, 1);
|
||||
QCOMPARE(before.message(), "File2.txt added\n");
|
||||
rebaseAboutToRebase++;
|
||||
});
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitInvalid, [=](){QVERIFY(false);}); // Should not be called
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseFinished, [=, &rebaseFinished](){rebaseFinished++;});
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitSuccess, [=, &rebaseCommitSuccess](const Rebase rebase, const Commit before, const Commit after, int counter, LogEntry* parent) {
|
||||
QVERIFY(rebase.isValid());
|
||||
rebaseCommitSuccess++;
|
||||
});
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseConflict, [=, &rebaseConflict](){
|
||||
rebaseConflict++;
|
||||
});
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseInitError, [=](){QVERIFY(false);}); // Should not be called
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseAboutToRebase, [=, &rebaseAboutToRebase](const Rebase rebase, const Commit before, int count, LogEntry* parent){
|
||||
// QVERIFY(rebase.isValid());
|
||||
// QCOMPARE(count, 1);
|
||||
// QCOMPARE(before.message(), "File2.txt added\n");
|
||||
// rebaseAboutToRebase++;
|
||||
// });
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitInvalid, [=](){QVERIFY(false);}); // Should not be called
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseFinished, [=, &rebaseFinished](){rebaseFinished++;});
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitSuccess, [=, &rebaseCommitSuccess](const Rebase rebase, const Commit before, const Commit after, int counter, LogEntry* parent) {
|
||||
// QVERIFY(rebase.isValid());
|
||||
// rebaseCommitSuccess++;
|
||||
// });
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseConflict, [=, &rebaseConflict](){
|
||||
// rebaseConflict++;
|
||||
// });
|
||||
|
||||
const QString rebaseBranchName = "refs/heads/noConflict";
|
||||
// const QString rebaseBranchName = "refs/heads/noConflict";
|
||||
|
||||
git::Reference branch = mRepo.lookupRef(rebaseBranchName);
|
||||
QVERIFY(branch.isValid());
|
||||
auto c = branch.annotatedCommit().commit();
|
||||
// git::Reference branch = mRepo.lookupRef(rebaseBranchName);
|
||||
// QVERIFY(branch.isValid());
|
||||
// auto c = branch.annotatedCommit().commit();
|
||||
|
||||
// Checkout correct branch
|
||||
QCOMPARE(mRepo.checkout(c), true);
|
||||
// // Checkout correct branch
|
||||
// QCOMPARE(mRepo.checkout(c), true);
|
||||
|
||||
// Rebase on main
|
||||
git::Reference mainBranch = mRepo.lookupRef(QString("refs/heads/main"));
|
||||
QVERIFY(mainBranch.isValid());
|
||||
auto ac = mainBranch.annotatedCommit();
|
||||
mRepo.rebase(ac);
|
||||
// // Rebase on main
|
||||
// git::Reference mainBranch = mRepo.lookupRef(QString("refs/heads/main"));
|
||||
// QVERIFY(mainBranch.isValid());
|
||||
// auto ac = mainBranch.annotatedCommit();
|
||||
// mRepo.rebase(ac);
|
||||
|
||||
// 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());
|
||||
// // 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());
|
||||
|
||||
// Check that rebase was really finished
|
||||
QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
// // Check that rebase was really finished
|
||||
// QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
|
||||
// Check call counters
|
||||
QCOMPARE(rebaseFinished, 1);
|
||||
QCOMPARE(rebaseAboutToRebase, 1);
|
||||
QCOMPARE(rebaseCommitSuccess, 1);
|
||||
QCOMPARE(rebaseConflict, 0);
|
||||
// // Check call counters
|
||||
// QCOMPARE(rebaseFinished, 1);
|
||||
// QCOMPARE(rebaseAboutToRebase, 1);
|
||||
// QCOMPARE(rebaseCommitSuccess, 1);
|
||||
// QCOMPARE(rebaseConflict, 0);
|
||||
}
|
||||
|
||||
void TestRebase::conflictingRebase() {
|
||||
INIT_REPO("rebaseConflicts.zip", false);
|
||||
// INIT_REPO("rebaseConflicts.zip", false);
|
||||
|
||||
int rebaseFinished = 0;
|
||||
int rebaseAboutToRebase = 0;
|
||||
int rebaseCommitSuccess = 0;
|
||||
int rebaseConflict = 0;
|
||||
int refreshTriggered = 0;
|
||||
// int rebaseFinished = 0;
|
||||
// int rebaseAboutToRebase = 0;
|
||||
// int rebaseCommitSuccess = 0;
|
||||
// int rebaseConflict = 0;
|
||||
// int refreshTriggered = 0;
|
||||
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseInitError, [=](){QVERIFY(false);}); // Should not be called
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseAboutToRebase, [=, &rebaseAboutToRebase](const Rebase rebase, const Commit before, int count, LogEntry* parent){
|
||||
QVERIFY(rebase.isValid());
|
||||
QCOMPARE(count, 1);
|
||||
QCOMPARE(before.message(), "File.txt changed by second branch\n");
|
||||
rebaseAboutToRebase++;
|
||||
});
|
||||
// TODO: = needed?
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitInvalid, [=](){QVERIFY(false);}); // Should not be called
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseFinished, [=, &rebaseFinished](){rebaseFinished++;});
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitSuccess, [=, &rebaseCommitSuccess](const Rebase rebase, const Commit before, const Commit after, int counter, LogEntry* parent) {
|
||||
QVERIFY(rebase.isValid());
|
||||
rebaseCommitSuccess++;
|
||||
});
|
||||
connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseConflict, [=, &rebaseConflict, &rebaseCommitSuccess](){
|
||||
QCOMPARE(rebaseCommitSuccess, 0); // was not called yet
|
||||
rebaseConflict++;
|
||||
});
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseInitError, [=](){QVERIFY(false);}); // Should not be called
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseAboutToRebase, [=, &rebaseAboutToRebase](const Rebase rebase, const Commit before, int count, LogEntry* parent){
|
||||
// QVERIFY(rebase.isValid());
|
||||
// QCOMPARE(count, 1);
|
||||
// QCOMPARE(before.message(), "File.txt changed by second branch\n");
|
||||
// rebaseAboutToRebase++;
|
||||
// });
|
||||
// // TODO: = needed?
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitInvalid, [=](){QVERIFY(false);}); // Should not be called
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseFinished, [=, &rebaseFinished](){rebaseFinished++;});
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseCommitSuccess, [=, &rebaseCommitSuccess](const Rebase rebase, const Commit before, const Commit after, int counter, LogEntry* parent) {
|
||||
// QVERIFY(rebase.isValid());
|
||||
// rebaseCommitSuccess++;
|
||||
// });
|
||||
// connect(mRepo.notifier(), &git::RepositoryNotifier::rebaseConflict, [=, &rebaseConflict, &rebaseCommitSuccess](){
|
||||
// QCOMPARE(rebaseCommitSuccess, 0); // was not called yet
|
||||
// rebaseConflict++;
|
||||
// });
|
||||
|
||||
connect(mRepo.notifier(), &RepositoryNotifier::referenceUpdated, [this, &refreshTriggered](const Reference &ref) {
|
||||
QCOMPARE(ref, mRepo.head());
|
||||
refreshTriggered++;
|
||||
});
|
||||
// connect(mRepo.notifier(), &RepositoryNotifier::referenceUpdated, [this, &refreshTriggered](const Reference &ref) {
|
||||
// QCOMPARE(ref, mRepo.head());
|
||||
// refreshTriggered++;
|
||||
// });
|
||||
|
||||
const QString rebaseBranchName = "refs/heads/singleCommitConflict";
|
||||
// const QString rebaseBranchName = "refs/heads/singleCommitConflict";
|
||||
|
||||
git::Reference branch = mRepo.lookupRef(rebaseBranchName);
|
||||
QVERIFY(branch.isValid());
|
||||
auto c = branch.annotatedCommit().commit();
|
||||
// git::Reference branch = mRepo.lookupRef(rebaseBranchName);
|
||||
// QVERIFY(branch.isValid());
|
||||
// auto c = branch.annotatedCommit().commit();
|
||||
|
||||
// Checkout correct branch
|
||||
QCOMPARE(mRepo.checkout(c), true);
|
||||
// // Checkout correct branch
|
||||
// QCOMPARE(mRepo.checkout(c), true);
|
||||
|
||||
// Rebase on main
|
||||
git::Reference mainBranch = mRepo.lookupRef(QString("refs/heads/main"));
|
||||
QVERIFY(mainBranch.isValid());
|
||||
auto ac = mainBranch.annotatedCommit();
|
||||
refreshTriggered = 0;
|
||||
mRepo.rebase(ac);
|
||||
QCOMPARE(refreshTriggered, 1); // Check that refresh was triggered
|
||||
// // Rebase on main
|
||||
// git::Reference mainBranch = mRepo.lookupRef(QString("refs/heads/main"));
|
||||
// QVERIFY(mainBranch.isValid());
|
||||
// auto ac = mainBranch.annotatedCommit();
|
||||
// refreshTriggered = 0;
|
||||
// mRepo.rebase(ac);
|
||||
// QCOMPARE(refreshTriggered, 1); // Check that refresh was triggered
|
||||
|
||||
QCOMPARE(mRepo.rebaseOngoing(), true);
|
||||
QCOMPARE(rebaseFinished, 0);
|
||||
QCOMPARE(rebaseConflict, 1);
|
||||
// TODO: check toolbar buttons
|
||||
// QCOMPARE(mRepo.rebaseOngoing(), true);
|
||||
// QCOMPARE(rebaseFinished, 0);
|
||||
// QCOMPARE(rebaseConflict, 1);
|
||||
// // TODO: check toolbar buttons
|
||||
|
||||
// Resolve conflicts
|
||||
diff = mRepo.status(mRepo.index(), nullptr, false);
|
||||
QCOMPARE(diff.count(), 1);
|
||||
QCOMPARE(diff.patch(0).isConflicted(), true);
|
||||
QFile f(diff.patch(0).name());
|
||||
QCOMPARE(f.open(QIODevice::WriteOnly), true);
|
||||
f.write("Test123"); // just write something to resolve the conflict
|
||||
// // Resolve conflicts
|
||||
// diff = mRepo.status(mRepo.index(), nullptr, false);
|
||||
// QCOMPARE(diff.count(), 1);
|
||||
// QCOMPARE(diff.patch(0).isConflicted(), true);
|
||||
// QFile f(diff.patch(0).name());
|
||||
// QCOMPARE(f.open(QIODevice::WriteOnly), true);
|
||||
// f.write("Test123"); // just write something to resolve the conflict
|
||||
|
||||
refreshTriggered = 0;
|
||||
rebaseConflict = 0;
|
||||
mRepo.rebaseContinue("Test message", nullptr);
|
||||
QCOMPARE(refreshTriggered, 1);
|
||||
// TODO: check toolbar buttons
|
||||
// refreshTriggered = 0;
|
||||
// rebaseConflict = 0;
|
||||
// mRepo.rebaseContinue("Test message", nullptr);
|
||||
// QCOMPARE(refreshTriggered, 1);
|
||||
// // TODO: check toolbar buttons
|
||||
|
||||
// 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"); // custom message was used instead of the original one
|
||||
// // 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"); // custom message was used instead of the original one
|
||||
|
||||
// Check that rebase was really finished
|
||||
QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
// // Check that rebase was really finished
|
||||
// QCOMPARE(mRepo.rebaseOngoing(), false);
|
||||
|
||||
// Check call counters
|
||||
QCOMPARE(rebaseFinished, 1);
|
||||
QCOMPARE(rebaseAboutToRebase, 1);
|
||||
QCOMPARE(rebaseCommitSuccess, 1);
|
||||
QCOMPARE(rebaseConflict, 0);
|
||||
// // Check call counters
|
||||
// QCOMPARE(rebaseFinished, 1);
|
||||
// QCOMPARE(rebaseAboutToRebase, 1);
|
||||
// QCOMPARE(rebaseCommitSuccess, 1);
|
||||
// QCOMPARE(rebaseConflict, 0);
|
||||
}
|
||||
|
||||
void TestRebase::continueExternalStartedRebase() {
|
||||
|
Loading…
Reference in New Issue
Block a user