2022-02-20 13:26:15 +08:00
|
|
|
#include "gitmergedialog.h"
|
|
|
|
#include "ui_gitmergedialog.h"
|
|
|
|
#include "gitmanager.h"
|
2022-02-20 21:47:57 +08:00
|
|
|
#include "../widgets/infomessagebox.h"
|
2022-02-20 13:26:15 +08:00
|
|
|
|
|
|
|
GitMergeDialog::GitMergeDialog(const QString& folder, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
2022-02-20 21:47:57 +08:00
|
|
|
ui(new Ui::GitMergeDialog)
|
2022-02-20 13:26:15 +08:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
mManager = new GitManager();
|
2022-02-20 21:47:57 +08:00
|
|
|
mCurrentBranchIndex=-1;
|
|
|
|
QStringList branches =mManager->listBranches(mFolder,mCurrentBranchIndex);
|
|
|
|
ui->cbBranch->addItems(branches);
|
|
|
|
ui->cbBranch->setCurrentIndex(mCurrentBranchIndex);
|
|
|
|
ui->btnOk->setEnabled(false);
|
|
|
|
ui->rbBranch->setChecked(true);
|
|
|
|
ui->txtMergeMessage->setPlainText(QObject::tr("<Auto Generated by Git>"));
|
|
|
|
mFolder = mManager->rootFolder(folder);
|
|
|
|
if (branches.isEmpty()) {
|
|
|
|
QString currentBranch;
|
|
|
|
if (mManager->hasRepository(folder,currentBranch)) {
|
|
|
|
ui->cbBranch->addItem(currentBranch);
|
|
|
|
ui->btnOk->setEnabled(false);
|
|
|
|
}
|
|
|
|
ui->grpOptions->setEnabled(false);
|
|
|
|
ui->txtMergeMessage->setEnabled(false);
|
|
|
|
}
|
2022-02-20 13:26:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GitMergeDialog::~GitMergeDialog()
|
|
|
|
{
|
|
|
|
delete mManager;
|
|
|
|
delete ui;
|
|
|
|
}
|
2022-02-20 21:47:57 +08:00
|
|
|
|
|
|
|
void GitMergeDialog::on_btnCancel_clicked()
|
|
|
|
{
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GitMergeDialog::closeEvent(QCloseEvent */* event */)
|
|
|
|
{
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GitMergeDialog::on_btnOk_clicked()
|
|
|
|
{
|
|
|
|
QString output;
|
|
|
|
if (mManager->merge(mFolder,ui->cbBranch->currentText(),
|
|
|
|
ui->chkSquash->isChecked(),
|
|
|
|
ui->chkFastForwardOnly->isChecked(),
|
|
|
|
ui->chkNoFastFoward->isChecked(),
|
|
|
|
ui->chkNoCommit->isChecked(),
|
|
|
|
output,
|
|
|
|
ui->txtMergeMessage->toPlainText()
|
|
|
|
)) {
|
2022-02-21 11:37:29 +08:00
|
|
|
InfoMessageBox box;
|
|
|
|
box.setMessage(output);
|
|
|
|
box.exec();
|
2022-02-20 21:47:57 +08:00
|
|
|
accept();
|
|
|
|
} else {
|
|
|
|
InfoMessageBox box;
|
|
|
|
box.setMessage(output);
|
|
|
|
box.exec();
|
|
|
|
reject();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GitMergeDialog::on_cbBranch_currentIndexChanged(int index)
|
|
|
|
{
|
|
|
|
ui->btnOk->setEnabled(mCurrentBranchIndex!=index);
|
|
|
|
}
|
|
|
|
|