add possibility to force commiting so in the rebase test it can forced which is needed because during rebase operation we are on a detached head

This commit is contained in:
Martin Marmsoler 2022-07-13 09:53:24 +02:00
parent 9b3ad12be6
commit c08dde3813
5 changed files with 9 additions and 8 deletions

View File

@ -971,14 +971,14 @@ public:
layout->addLayout(buttonLayout);
}
void commit() {
void commit(bool force = false) {
// Check for a merge head.
git::AnnotatedCommit upstream;
RepoView *view = RepoView::parentView(this);
if (git::Reference mergeHead = view->repo().lookupRef("MERGE_HEAD")) // TODO: is it possible to use instead of the string GIT_MERGE_HEAD_FILE?
upstream = mergeHead.annotatedCommit();
if (view->commit(mMessage->toPlainText(), upstream))
if (view->commit(mMessage->toPlainText(), upstream, nullptr, force))
mMessage->clear(); // Clear the message field.
}
@ -1271,9 +1271,9 @@ DetailView::DetailView(const git::Repository &repo, QWidget *parent)
DetailView::~DetailView() {}
void DetailView::commit() {
void DetailView::commit(bool force) {
Q_ASSERT(isCommitEnabled());
static_cast<CommitEditor *>(mDetail->currentWidget())->commit();
static_cast<CommitEditor *>(mDetail->currentWidget())->commit(force);
}
bool DetailView::isCommitEnabled() const {

View File

@ -49,7 +49,7 @@ public:
virtual ~DetailView();
// commit
void commit();
void commit(bool force = false);
bool isCommitEnabled() const;
bool isRebaseContinueVisible() const;
bool isRebaseAbortVisible() const;

View File

@ -475,7 +475,7 @@ void RepoView::selectHead() { mRefs->select(mRepo.head()); }
void RepoView::selectFirstCommit() { mCommits->selectFirstCommit(); }
void RepoView::commit() { mDetails->commit(); }
void RepoView::commit(bool force) { mDetails->commit(force); }
bool RepoView::isCommitEnabled() const { return mDetails->isCommitEnabled(); }

View File

@ -90,7 +90,7 @@ public:
bool lfsSetLocked(const QStringList &paths, bool locked);
// commit
void commit();
void commit(bool force = false);
bool isCommitEnabled() const;
// stage / unstage

View File

@ -702,7 +702,8 @@ void TestRebase::commitDuringRebase() {
// Do commit before going on
// So the user can commit between the rebase to split up the changes
repoView->commit();
bool force = true;
repoView->commit(force);
refreshTriggered = 0;
rebaseConflict = 0;