- enhancement: git - merge
This commit is contained in:
parent
47e4fee047
commit
45bb056713
1
NEWS.md
1
NEWS.md
|
@ -13,6 +13,7 @@ Red Panda C++ Version 0.14.3
|
||||||
- enhancement: git - commit
|
- enhancement: git - commit
|
||||||
- enhancement: git - restore
|
- enhancement: git - restore
|
||||||
- enhancement: git - branch / switch
|
- enhancement: git - branch / switch
|
||||||
|
- enhancement: git - merge
|
||||||
- fix: compiler set index not correctly saved, when remove compiler sets in options dialog
|
- fix: compiler set index not correctly saved, when remove compiler sets in options dialog
|
||||||
- enhancement: when create a repository in a project, auto add it's files to the repository
|
- enhancement: when create a repository in a project, auto add it's files to the repository
|
||||||
- enhancement: when add files to project, auto add it to git (if the project has a git repository)
|
- enhancement: when add files to project, auto add it to git (if the project has a git repository)
|
||||||
|
|
|
@ -93,6 +93,7 @@ SOURCES += \
|
||||||
toolsmanager.cpp \
|
toolsmanager.cpp \
|
||||||
vcs/gitbranchdialog.cpp \
|
vcs/gitbranchdialog.cpp \
|
||||||
vcs/gitmanager.cpp \
|
vcs/gitmanager.cpp \
|
||||||
|
vcs/gitmergedialog.cpp \
|
||||||
vcs/gitrepository.cpp \
|
vcs/gitrepository.cpp \
|
||||||
vcs/gitutils.cpp \
|
vcs/gitutils.cpp \
|
||||||
widgets/aboutdialog.cpp \
|
widgets/aboutdialog.cpp \
|
||||||
|
@ -226,6 +227,7 @@ HEADERS += \
|
||||||
toolsmanager.h \
|
toolsmanager.h \
|
||||||
vcs/gitbranchdialog.h \
|
vcs/gitbranchdialog.h \
|
||||||
vcs/gitmanager.h \
|
vcs/gitmanager.h \
|
||||||
|
vcs/gitmergedialog.h \
|
||||||
vcs/gitrepository.h \
|
vcs/gitrepository.h \
|
||||||
vcs/gitutils.h \
|
vcs/gitutils.h \
|
||||||
widgets/aboutdialog.h \
|
widgets/aboutdialog.h \
|
||||||
|
@ -322,6 +324,7 @@ FORMS += \
|
||||||
settingsdialog/toolsgeneralwidget.ui \
|
settingsdialog/toolsgeneralwidget.ui \
|
||||||
settingsdialog/toolsgitwidget.ui \
|
settingsdialog/toolsgitwidget.ui \
|
||||||
vcs/gitbranchdialog.ui \
|
vcs/gitbranchdialog.ui \
|
||||||
|
vcs/gitmergedialog.ui \
|
||||||
widgets/aboutdialog.ui \
|
widgets/aboutdialog.ui \
|
||||||
widgets/cpudialog.ui \
|
widgets/cpudialog.ui \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
|
|
|
@ -170,7 +170,9 @@ QStringList GitManager::listBranches(const QString &folder, int ¤t)
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::switchToBranch(const QString &folder, const QString &branch, bool create, bool force, bool merge, bool track, bool noTrack, bool forceCreation)
|
bool GitManager::switchToBranch(const QString &folder, const QString &branch,
|
||||||
|
bool create, bool force, bool merge, bool track,
|
||||||
|
bool noTrack, bool forceCreation, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("switch");
|
args.append("switch");
|
||||||
|
@ -187,8 +189,51 @@ bool GitManager::switchToBranch(const QString &folder, const QString &branch, bo
|
||||||
else if (noTrack)
|
else if (noTrack)
|
||||||
args.append("--no-track");
|
args.append("--no-track");
|
||||||
args.append(branch);
|
args.append(branch);
|
||||||
|
output = runGit(folder,args);
|
||||||
|
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::merge(const QString &folder, const QString &commit, bool squash,
|
||||||
|
bool fastForwardOnly, bool noFastForward, bool noCommit,
|
||||||
|
QString& output,
|
||||||
|
const QString& commitMessage)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args.append("merge");
|
||||||
|
if (squash)
|
||||||
|
args.append("--squash");
|
||||||
|
if (fastForwardOnly)
|
||||||
|
args.append("--ff-only");
|
||||||
|
else if (noFastForward)
|
||||||
|
args.append("--no-ff");
|
||||||
|
if (noCommit)
|
||||||
|
args.append("--no-commit");
|
||||||
|
if (!commitMessage.isEmpty()
|
||||||
|
&& commitMessage != QObject::tr("<Auto Generated by Git>")){
|
||||||
|
args.append("-m");
|
||||||
|
args.append(commitMessage);
|
||||||
|
}
|
||||||
|
args.append(commit);
|
||||||
|
output = runGit(folder,args);
|
||||||
|
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::continueMerge(const QString &folder)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args.append("merge");
|
||||||
|
args.append("--continue");
|
||||||
QString output = runGit(folder,args);
|
QString output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return !output.startsWith("error") && !output.startsWith("fatal");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitManager::abortMerge(const QString &folder)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args.append("merge");
|
||||||
|
args.append("--abort");
|
||||||
|
runGit(folder,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::clone(const QString &folder, const QString &url)
|
void GitManager::clone(const QString &folder, const QString &url)
|
||||||
|
|
|
@ -38,7 +38,15 @@ public:
|
||||||
QStringList listChangedFiles(const QString& folder);
|
QStringList listChangedFiles(const QString& folder);
|
||||||
QStringList listBranches(const QString& folder, int& current);
|
QStringList listBranches(const QString& folder, int& current);
|
||||||
bool switchToBranch(const QString& folder, const QString& branch, bool create,
|
bool switchToBranch(const QString& folder, const QString& branch, bool create,
|
||||||
bool force, bool merge, bool track, bool noTrack, bool forceCreation );
|
bool force, bool merge, bool track, bool noTrack, bool forceCreation,
|
||||||
|
QString& output);
|
||||||
|
bool merge(const QString& folder, const QString& commit, bool squash, bool fastForwardOnly,
|
||||||
|
bool noFastForward, bool noCommit,
|
||||||
|
QString& output,
|
||||||
|
const QString& commitMessage=QString()
|
||||||
|
);
|
||||||
|
bool continueMerge(const QString& folder);
|
||||||
|
void abortMerge(const QString& folder);
|
||||||
|
|
||||||
void clone(const QString& folder, const QString& url);
|
void clone(const QString& folder, const QString& url);
|
||||||
void commit(const QString& folder, const QString& message, bool autoStage);
|
void commit(const QString& folder, const QString& message, bool autoStage);
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include "gitmergedialog.h"
|
||||||
|
#include "ui_gitmergedialog.h"
|
||||||
|
#include "gitmanager.h"
|
||||||
|
|
||||||
|
GitMergeDialog::GitMergeDialog(const QString& folder, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::GitMergeDialog),
|
||||||
|
mFolder(folder)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
mManager = new GitManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
GitMergeDialog::~GitMergeDialog()
|
||||||
|
{
|
||||||
|
delete mManager;
|
||||||
|
delete ui;
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef GITMERGEDIALOG_H
|
||||||
|
#define GITMERGEDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class GitMergeDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GitManager;
|
||||||
|
class GitMergeDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GitMergeDialog(const QString& folder, QWidget *parent = nullptr);
|
||||||
|
~GitMergeDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::GitMergeDialog *ui;
|
||||||
|
GitManager *mManager;
|
||||||
|
QString mFolder;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GITMERGEDIALOG_H
|
|
@ -0,0 +1,147 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>GitMergeDialog</class>
|
||||||
|
<widget class="QDialog" name="GitMergeDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>597</width>
|
||||||
|
<height>508</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>From</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QRadioButton" name="rbBranch">
|
||||||
|
<property name="text">
|
||||||
|
<string>Branch</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="cbBranch">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="grpOptions">
|
||||||
|
<property name="title">
|
||||||
|
<string>Option</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkNoCommit">
|
||||||
|
<property name="text">
|
||||||
|
<string>No Commit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QCheckBox" name="chkSquash">
|
||||||
|
<property name="text">
|
||||||
|
<string>Squash</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="chkNoFastFoward">
|
||||||
|
<property name="text">
|
||||||
|
<string>No Fast Forward</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="chkFastForwardOnly">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fast Forward Only</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_3">
|
||||||
|
<property name="title">
|
||||||
|
<string>Merge Message</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="txtMergeMessage"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnOk">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ok</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnCancel">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -9,4 +9,25 @@ enum class GitResetStrategy {
|
||||||
Keep
|
Keep
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class GitMergeStrategy {
|
||||||
|
Resolve,
|
||||||
|
Recursive,
|
||||||
|
Ours,
|
||||||
|
Subtree
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class GitMergeStrategyOption {
|
||||||
|
Ours,
|
||||||
|
Theirs,
|
||||||
|
Patience,
|
||||||
|
Ignore_Space_Change,
|
||||||
|
Ignore_All_Space,
|
||||||
|
Ignore_Space_At_Eol,
|
||||||
|
Renormalize,
|
||||||
|
No_Renormalize,
|
||||||
|
Find_Names,
|
||||||
|
Rename_Threshold,
|
||||||
|
Subtree
|
||||||
|
};
|
||||||
|
|
||||||
#endif // GITUTILS_H
|
#endif // GITUTILS_H
|
||||||
|
|
Loading…
Reference in New Issue