add dialog to set git user infos
This commit is contained in:
parent
3df0c98031
commit
2084990491
|
@ -101,6 +101,7 @@ SOURCES += \
|
||||||
vcs/gitremotedialog.cpp \
|
vcs/gitremotedialog.cpp \
|
||||||
vcs/gitrepository.cpp \
|
vcs/gitrepository.cpp \
|
||||||
vcs/gitresetdialog.cpp \
|
vcs/gitresetdialog.cpp \
|
||||||
|
vcs/gituserconfigdialog.cpp \
|
||||||
vcs/gitutils.cpp \
|
vcs/gitutils.cpp \
|
||||||
widgets/aboutdialog.cpp \
|
widgets/aboutdialog.cpp \
|
||||||
widgets/bookmarkmodel.cpp \
|
widgets/bookmarkmodel.cpp \
|
||||||
|
@ -243,6 +244,7 @@ HEADERS += \
|
||||||
vcs/gitremotedialog.h \
|
vcs/gitremotedialog.h \
|
||||||
vcs/gitrepository.h \
|
vcs/gitrepository.h \
|
||||||
vcs/gitresetdialog.h \
|
vcs/gitresetdialog.h \
|
||||||
|
vcs/gituserconfigdialog.h \
|
||||||
vcs/gitutils.h \
|
vcs/gitutils.h \
|
||||||
widgets/aboutdialog.h \
|
widgets/aboutdialog.h \
|
||||||
widgets/bookmarkmodel.h \
|
widgets/bookmarkmodel.h \
|
||||||
|
@ -347,6 +349,7 @@ FORMS += \
|
||||||
vcs/gitpushdialog.ui \
|
vcs/gitpushdialog.ui \
|
||||||
vcs/gitremotedialog.ui \
|
vcs/gitremotedialog.ui \
|
||||||
vcs/gitresetdialog.ui \
|
vcs/gitresetdialog.ui \
|
||||||
|
vcs/gituserconfigdialog.ui \
|
||||||
widgets/aboutdialog.ui \
|
widgets/aboutdialog.ui \
|
||||||
widgets/choosethemedialog.ui \
|
widgets/choosethemedialog.ui \
|
||||||
widgets/cpudialog.ui \
|
widgets/cpudialog.ui \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,6 +45,7 @@
|
||||||
#include "vcs/gitmergedialog.h"
|
#include "vcs/gitmergedialog.h"
|
||||||
#include "vcs/gitlogdialog.h"
|
#include "vcs/gitlogdialog.h"
|
||||||
#include "vcs/gitremotedialog.h"
|
#include "vcs/gitremotedialog.h"
|
||||||
|
#include "vcs/gituserconfigdialog.h"
|
||||||
#include "widgets/infomessagebox.h"
|
#include "widgets/infomessagebox.h"
|
||||||
|
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
|
@ -768,7 +769,8 @@ void MainWindow::onFileSaved(const QString &path, bool inProject)
|
||||||
if (!inProject) {
|
if (!inProject) {
|
||||||
if ( (isCFile(path) || isHFile(path))
|
if ( (isCFile(path) || isHFile(path))
|
||||||
&& !mFileSystemModelIconProvider.VCSRepository()->isFileInRepository(path)) {
|
&& !mFileSystemModelIconProvider.VCSRepository()->isFileInRepository(path)) {
|
||||||
mFileSystemModelIconProvider.VCSRepository()->add(extractRelativePath(mFileSystemModelIconProvider.VCSRepository()->folder(),path));
|
QString output;
|
||||||
|
mFileSystemModelIconProvider.VCSRepository()->add(extractRelativePath(mFileSystemModelIconProvider.VCSRepository()->folder(),path),output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// qDebug()<<"update icon provider";
|
// qDebug()<<"update icon provider";
|
||||||
|
@ -5458,8 +5460,10 @@ void MainWindow::on_actionAdd_to_project_triggered()
|
||||||
mProject->cppParser()->addFileToScan(filename);
|
mProject->cppParser()->addFileToScan(filename);
|
||||||
QString branch;
|
QString branch;
|
||||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||||
|
QString output;
|
||||||
mProject->model()->iconProvider()->VCSRepository()->add(
|
mProject->model()->iconProvider()->VCSRepository()->add(
|
||||||
extractRelativePath(mProject->folder(),filename)
|
extractRelativePath(mProject->folder(),filename),
|
||||||
|
output
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5713,7 +5717,8 @@ void MainWindow::newProjectUnitFile()
|
||||||
editor->activate();
|
editor->activate();
|
||||||
QString branch;
|
QString branch;
|
||||||
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
if (pSettings->vcs().gitOk() && mProject->model()->iconProvider()->VCSRepository()->hasRepository(branch)) {
|
||||||
mProject->model()->iconProvider()->VCSRepository()->add(newFileName);
|
QString output;
|
||||||
|
mProject->model()->iconProvider()->VCSRepository()->add(newFileName,output);
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->beginUpdate();
|
||||||
mProject->model()->endUpdate();
|
mProject->model()->endUpdate();
|
||||||
}
|
}
|
||||||
|
@ -6719,10 +6724,11 @@ void MainWindow::on_actionGit_Create_Repository_triggered()
|
||||||
} else if (ui->projectView->isVisible() && mProject) {
|
} else if (ui->projectView->isVisible() && mProject) {
|
||||||
GitManager vcsManager;
|
GitManager vcsManager;
|
||||||
vcsManager.createRepository(mProject->folder());
|
vcsManager.createRepository(mProject->folder());
|
||||||
vcsManager.add(mProject->folder(), extractFileName(mProject->filename()));
|
QString output;
|
||||||
vcsManager.add(mProject->folder(), extractFileName(mProject->options().icon));
|
vcsManager.add(mProject->folder(), extractFileName(mProject->filename()), output);
|
||||||
|
vcsManager.add(mProject->folder(), extractFileName(mProject->options().icon), output);
|
||||||
foreach (PProjectUnit pUnit, mProject->units()) {
|
foreach (PProjectUnit pUnit, mProject->units()) {
|
||||||
vcsManager.add(mProject->folder(),extractRelativePath(mProject->folder(),pUnit->fileName()));
|
vcsManager.add(mProject->folder(),extractRelativePath(mProject->folder(),pUnit->fileName()),output);
|
||||||
}
|
}
|
||||||
//update project view
|
//update project view
|
||||||
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode(), true);
|
mProject->addUnit(includeTrailingPathDelimiter(mProject->folder())+".gitignore", mProject->rootNode(), true);
|
||||||
|
@ -6747,9 +6753,10 @@ void MainWindow::on_actionGit_Add_Files_triggered()
|
||||||
if (ui->treeFiles->isVisible()) {
|
if (ui->treeFiles->isVisible()) {
|
||||||
GitManager vcsManager;
|
GitManager vcsManager;
|
||||||
QModelIndexList indices = ui->treeFiles->selectionModel()->selectedRows();
|
QModelIndexList indices = ui->treeFiles->selectionModel()->selectedRows();
|
||||||
|
QString output;
|
||||||
foreach (const QModelIndex index,indices) {
|
foreach (const QModelIndex index,indices) {
|
||||||
QFileInfo info = mFileSystemModel.fileInfo(index);
|
QFileInfo info = mFileSystemModel.fileInfo(index);
|
||||||
vcsManager.add(info.absolutePath(),info.fileName());
|
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
||||||
}
|
}
|
||||||
//update icons in files view
|
//update icons in files view
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
|
@ -6766,7 +6773,8 @@ void MainWindow::on_actionGit_Add_Files_triggered()
|
||||||
if (folderNode->unitIndex>=0) {
|
if (folderNode->unitIndex>=0) {
|
||||||
PProjectUnit unit = mProject->units()[folderNode->unitIndex];
|
PProjectUnit unit = mProject->units()[folderNode->unitIndex];
|
||||||
QFileInfo info(unit->fileName());
|
QFileInfo info(unit->fileName());
|
||||||
vcsManager.add(info.absolutePath(),info.fileName());
|
QString output;
|
||||||
|
vcsManager.add(info.absolutePath(),info.fileName(),output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6811,8 +6819,19 @@ void MainWindow::on_actionGit_Commit_triggered()
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vcsManager.commit(folder,message,true);
|
QString output;
|
||||||
|
QString userName = vcsManager.getUserName(folder);
|
||||||
|
QString userEmail = vcsManager.getUserEmail(folder);
|
||||||
|
if (userName.isEmpty() || userEmail.isEmpty()) {
|
||||||
|
GitUserConfigDialog dialog(folder);
|
||||||
|
if (dialog.exec()!=QDialog::Accepted) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Can't Commit"),
|
||||||
|
tr("Git needs user info to commit."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vcsManager.commit(folder,message,true,output)) {
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
mProject->model()->beginUpdate();
|
mProject->model()->beginUpdate();
|
||||||
|
@ -6822,6 +6841,11 @@ void MainWindow::on_actionGit_Commit_triggered()
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||||
}
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
InfoMessageBox infoBox;
|
||||||
|
infoBox.showMessage(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionGit_Restore_triggered()
|
void MainWindow::on_actionGit_Restore_triggered()
|
||||||
|
@ -6835,7 +6859,8 @@ void MainWindow::on_actionGit_Restore_triggered()
|
||||||
if (folder.isEmpty())
|
if (folder.isEmpty())
|
||||||
return;
|
return;
|
||||||
GitManager vcsManager;
|
GitManager vcsManager;
|
||||||
vcsManager.restore(folder,"");
|
QString output;
|
||||||
|
if (vcsManager.restore(folder,"",output)) {
|
||||||
|
|
||||||
//update project view
|
//update project view
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
|
@ -6846,6 +6871,11 @@ void MainWindow::on_actionGit_Restore_triggered()
|
||||||
mFileSystemModelIconProvider.update();
|
mFileSystemModelIconProvider.update();
|
||||||
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
mFileSystemModel.setIconProvider(&mFileSystemModelIconProvider);
|
||||||
}
|
}
|
||||||
|
if (!output.isEmpty()) {
|
||||||
|
InfoMessageBox infoBox;
|
||||||
|
infoBox.showMessage(output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_actionWebsite_triggered()
|
void MainWindow::on_actionWebsite_triggered()
|
||||||
|
|
|
@ -29,7 +29,8 @@ void GitManager::createRepository(const QString &folder)
|
||||||
|
|
||||||
QDir dir(folder);
|
QDir dir(folder);
|
||||||
stringsToFile(contents,dir.filePath(".gitignore"));
|
stringsToFile(contents,dir.filePath(".gitignore"));
|
||||||
add(folder,".gitignore");
|
QString output;
|
||||||
|
add(folder,".gitignore",output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::hasRepository(const QString &folder, QString& currentBranch)
|
bool GitManager::hasRepository(const QString &folder, QString& currentBranch)
|
||||||
|
@ -93,32 +94,36 @@ bool GitManager::isFileChanged(const QFileInfo &fileInfo)
|
||||||
return output.trimmed() == fileInfo.fileName();
|
return output.trimmed() == fileInfo.fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::add(const QString &folder, const QString &path)
|
bool GitManager::add(const QString &folder, const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("add");
|
args.append("add");
|
||||||
args.append(path);
|
args.append(path);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::remove(const QString &folder, const QString &path)
|
bool GitManager::remove(const QString &folder, const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("rm");
|
args.append("rm");
|
||||||
args.append(path);
|
args.append(path);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::rename(const QString &folder, const QString &oldName, const QString &newName)
|
bool GitManager::rename(const QString &folder, const QString &oldName,
|
||||||
|
const QString &newName, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("mv");
|
args.append("mv");
|
||||||
args.append(oldName);
|
args.append(oldName);
|
||||||
args.append(newName);
|
args.append(newName);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::restore(const QString &folder, const QString &path)
|
bool GitManager::restore(const QString &folder, const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("restore");
|
args.append("restore");
|
||||||
|
@ -126,7 +131,8 @@ void GitManager::restore(const QString &folder, const QString &path)
|
||||||
args.append(".");
|
args.append(".");
|
||||||
else
|
else
|
||||||
args.append(path);
|
args.append(path);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GitManager::logCounts(const QString &folder, const QString &branch)
|
int GitManager::logCounts(const QString &folder, const QString &branch)
|
||||||
|
@ -236,7 +242,7 @@ bool GitManager::removeRemote(const QString &folder, const QString &remoteName,
|
||||||
args.append(remoteName);
|
args.append(remoteName);
|
||||||
|
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::renameRemote(const QString &folder, const QString &oldName, const QString &newName, QString &output)
|
bool GitManager::renameRemote(const QString &folder, const QString &oldName, const QString &newName, QString &output)
|
||||||
|
@ -248,7 +254,7 @@ bool GitManager::renameRemote(const QString &folder, const QString &oldName, con
|
||||||
args.append(newName);
|
args.append(newName);
|
||||||
|
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::addRemote(const QString &folder, const QString &name, const QString &url, QString &output)
|
bool GitManager::addRemote(const QString &folder, const QString &name, const QString &url, QString &output)
|
||||||
|
@ -260,7 +266,7 @@ bool GitManager::addRemote(const QString &folder, const QString &name, const QSt
|
||||||
args.append(url);
|
args.append(url);
|
||||||
|
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::setRemoteURL(const QString &folder, const QString &name, const QString &newURL, QString &output)
|
bool GitManager::setRemoteURL(const QString &folder, const QString &name, const QString &newURL, QString &output)
|
||||||
|
@ -272,7 +278,7 @@ bool GitManager::setRemoteURL(const QString &folder, const QString &name, const
|
||||||
args.append(newURL);
|
args.append(newURL);
|
||||||
|
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitManager::getRemoteURL(const QString &folder, const QString &name)
|
QString GitManager::getRemoteURL(const QString &folder, const QString &name)
|
||||||
|
@ -313,7 +319,7 @@ bool GitManager::setBranchUpstream(
|
||||||
args.append(QString("--set-upstream-to=%1/%2").arg(remoteName,branch));
|
args.append(QString("--set-upstream-to=%1/%2").arg(remoteName,branch));
|
||||||
args.append(branch);
|
args.append(branch);
|
||||||
output = runGit(folder,args).trimmed();
|
output = runGit(folder,args).trimmed();
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::fetch(const QString &folder, QString &output)
|
bool GitManager::fetch(const QString &folder, QString &output)
|
||||||
|
@ -321,7 +327,7 @@ bool GitManager::fetch(const QString &folder, QString &output)
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("fetch");
|
args.append("fetch");
|
||||||
output = runGit(folder,args).trimmed();
|
output = runGit(folder,args).trimmed();
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::pull(const QString &folder, QString &output)
|
bool GitManager::pull(const QString &folder, QString &output)
|
||||||
|
@ -329,7 +335,7 @@ bool GitManager::pull(const QString &folder, QString &output)
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("pull");
|
args.append("pull");
|
||||||
output = runGit(folder,args).trimmed();
|
output = runGit(folder,args).trimmed();
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::push(const QString &folder, QString &output)
|
bool GitManager::push(const QString &folder, QString &output)
|
||||||
|
@ -337,7 +343,7 @@ bool GitManager::push(const QString &folder, QString &output)
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("push");
|
args.append("push");
|
||||||
output = runGit(folder,args).trimmed();
|
output = runGit(folder,args).trimmed();
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::push(const QString &folder, const QString &remoteName, const QString &branch, QString &output)
|
bool GitManager::push(const QString &folder, const QString &remoteName, const QString &branch, QString &output)
|
||||||
|
@ -348,7 +354,58 @@ bool GitManager::push(const QString &folder, const QString &remoteName, const QS
|
||||||
args.append(remoteName);
|
args.append(remoteName);
|
||||||
args.append(branch);
|
args.append(branch);
|
||||||
output = runGit(folder,args).trimmed();
|
output = runGit(folder,args).trimmed();
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::removeConfig(const QString &folder, const QString &name, QString &output)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args.append("config");
|
||||||
|
args.append("--unset-all");
|
||||||
|
args.append(name);
|
||||||
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::setConfig(const QString &folder, const QString &name, const QString &value, QString &output)
|
||||||
|
{
|
||||||
|
removeConfig(folder,name,output);
|
||||||
|
QStringList args;
|
||||||
|
args.append("config");
|
||||||
|
args.append("--add");
|
||||||
|
args.append(name);
|
||||||
|
args.append(value);
|
||||||
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::setUserName(const QString &folder, const QString &userName, QString &output)
|
||||||
|
{
|
||||||
|
return setConfig(folder,"user.name",userName,output);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::setUserEmail(const QString &folder, const QString &userEmail, QString &output)
|
||||||
|
{
|
||||||
|
return setConfig(folder,"user.email",userEmail,output);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GitManager::getConfig(const QString& folder, const QString &name)
|
||||||
|
{
|
||||||
|
QStringList args;
|
||||||
|
args.append("config");
|
||||||
|
args.append("--get");
|
||||||
|
args.append(name);
|
||||||
|
return runGit(folder,args).trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GitManager::getUserName(const QString& folder)
|
||||||
|
{
|
||||||
|
return getConfig(folder, "user.name");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString GitManager::getUserEmail(const QString& folder)
|
||||||
|
{
|
||||||
|
return getConfig(folder, "user.email");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GitManager::listBranches(const QString &folder, int ¤t)
|
QStringList GitManager::listBranches(const QString &folder, int ¤t)
|
||||||
|
@ -393,7 +450,7 @@ bool GitManager::switchToBranch(const QString &folder, const QString &branch,
|
||||||
args.append("--no-track");
|
args.append("--no-track");
|
||||||
args.append(branch);
|
args.append(branch);
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::merge(const QString &folder, const QString &commit, bool squash,
|
bool GitManager::merge(const QString &folder, const QString &commit, bool squash,
|
||||||
|
@ -418,7 +475,7 @@ bool GitManager::merge(const QString &folder, const QString &commit, bool squash
|
||||||
}
|
}
|
||||||
args.append(commit);
|
args.append(commit);
|
||||||
output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::continueMerge(const QString &folder)
|
bool GitManager::continueMerge(const QString &folder)
|
||||||
|
@ -427,7 +484,7 @@ bool GitManager::continueMerge(const QString &folder)
|
||||||
args.append("merge");
|
args.append("merge");
|
||||||
args.append("--continue");
|
args.append("--continue");
|
||||||
QString output = runGit(folder,args);
|
QString output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,15 +496,30 @@ void GitManager::abortMerge(const QString &folder)
|
||||||
runGit(folder,args);
|
runGit(folder,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::clone(const QString &folder, const QString &url)
|
bool GitManager::isSuccess(const QString &output)
|
||||||
|
{
|
||||||
|
QStringList lst = textToLines(output);
|
||||||
|
if (!lst.isEmpty()) {
|
||||||
|
foreach (const QString& s, lst) {
|
||||||
|
QString last= s.trimmed();
|
||||||
|
if (last.startsWith("error:") || last.startsWith("fatal:"))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GitManager::clone(const QString &folder, const QString &url, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("clone");
|
args.append("clone");
|
||||||
args.append(url);
|
args.append(url);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::commit(const QString &folder, const QString &message, bool autoStage)
|
bool GitManager::commit(const QString &folder, const QString &message, bool autoStage, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("commit");
|
args.append("commit");
|
||||||
|
@ -455,19 +527,21 @@ void GitManager::commit(const QString &folder, const QString &message, bool auto
|
||||||
args.append("-a");
|
args.append("-a");
|
||||||
args.append("-m");
|
args.append("-m");
|
||||||
args.append(message);
|
args.append(message);
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitManager::revert(const QString &folder)
|
bool GitManager::revert(const QString &folder, QString& output)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args.append("revert");
|
args.append("revert");
|
||||||
runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::reset(const QString &folder, const QString &commit,
|
bool GitManager::reset(const QString &folder, const QString &commit,
|
||||||
GitResetStrategy strategy,
|
GitResetStrategy strategy,
|
||||||
QString& ouput)
|
QString& output)
|
||||||
{
|
{
|
||||||
//todo reset type
|
//todo reset type
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
@ -490,8 +564,8 @@ bool GitManager::reset(const QString &folder, const QString &commit,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
args.append(commit);
|
args.append(commit);
|
||||||
QString output = runGit(folder,args);
|
output = runGit(folder,args);
|
||||||
return !output.startsWith("error") && !output.startsWith("fatal");
|
return isSuccess(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GitManager::isValid()
|
bool GitManager::isValid()
|
||||||
|
@ -512,10 +586,16 @@ QString GitManager::runGit(const QString& workingFolder, const QStringList &args
|
||||||
args.join("\" \"")));
|
args.join("\" \"")));
|
||||||
// qDebug()<<"---------";
|
// qDebug()<<"---------";
|
||||||
// qDebug()<<args;
|
// qDebug()<<args;
|
||||||
|
QProcessEnvironment env;
|
||||||
|
env.insert("PATH",pSettings->dirs().appDir());
|
||||||
|
env.insert("GIT_ASKPASS",includeTrailingPathDelimiter(pSettings->dirs().appDir())+"redpanda-win-git-askpass.exe");
|
||||||
QString output = runAndGetOutput(
|
QString output = runAndGetOutput(
|
||||||
fileInfo.absoluteFilePath(),
|
fileInfo.absoluteFilePath(),
|
||||||
workingFolder,
|
workingFolder,
|
||||||
args);
|
args,
|
||||||
|
"",
|
||||||
|
false,
|
||||||
|
env);
|
||||||
output = escapeUTF8String(output.toUtf8());
|
output = escapeUTF8String(output.toUtf8());
|
||||||
// qDebug()<<output;
|
// qDebug()<<output;
|
||||||
emit gitCmdFinished(output);
|
emit gitCmdFinished(output);
|
||||||
|
|
|
@ -28,10 +28,10 @@ public:
|
||||||
bool isFileStaged(const QFileInfo& fileInfo);
|
bool isFileStaged(const QFileInfo& fileInfo);
|
||||||
bool isFileChanged(const QFileInfo& fileInfo);
|
bool isFileChanged(const QFileInfo& fileInfo);
|
||||||
|
|
||||||
void add(const QString& folder, const QString& path);
|
bool add(const QString& folder, const QString& path, QString& output);
|
||||||
void remove(const QString& folder, const QString& path);
|
bool remove(const QString& folder, const QString& path, QString& output);
|
||||||
void rename(const QString& folder, const QString& oldName, const QString& newName);
|
bool rename(const QString& folder, const QString& oldName, const QString& newName, QString& output);
|
||||||
void restore(const QString& folder, const QString& path);
|
bool restore(const QString& folder, const QString& path, QString& output);
|
||||||
|
|
||||||
int logCounts(const QString& folder, const QString& branch=QString());
|
int logCounts(const QString& folder, const QString& branch=QString());
|
||||||
QList<PGitCommitInfo> log(const QString& folder, int start, int count, const QString& branch=QString());
|
QList<PGitCommitInfo> log(const QString& folder, int start, int count, const QString& branch=QString());
|
||||||
|
@ -65,6 +65,15 @@ public:
|
||||||
const QString& branch,
|
const QString& branch,
|
||||||
QString& output);
|
QString& output);
|
||||||
|
|
||||||
|
bool removeConfig(const QString& folder, const QString &name, QString& output);
|
||||||
|
bool setConfig(const QString& folder, const QString &name, const QString &value, QString& output);
|
||||||
|
bool setUserName(const QString& folder, const QString& userName, QString& output);
|
||||||
|
bool setUserEmail(const QString& folder, const QString& userEmail, QString& output);
|
||||||
|
|
||||||
|
QString getConfig(const QString& folder, const QString& name);
|
||||||
|
QString getUserName(const QString& folder);
|
||||||
|
QString getUserEmail(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,
|
||||||
|
@ -78,9 +87,10 @@ public:
|
||||||
bool continueMerge(const QString& folder);
|
bool continueMerge(const QString& folder);
|
||||||
void abortMerge(const QString& folder);
|
void abortMerge(const QString& folder);
|
||||||
|
|
||||||
void clone(const QString& folder, const QString& url);
|
bool isSuccess(const QString& output);
|
||||||
void commit(const QString& folder, const QString& message, bool autoStage);
|
bool clone(const QString& folder, const QString& url, QString& output);
|
||||||
void revert(const QString& folder);
|
bool commit(const QString& folder, const QString& message, bool autoStage, QString& output);
|
||||||
|
bool revert(const QString& folder, QString& output);
|
||||||
bool reset(const QString& folder, const QString& commit, GitResetStrategy strategy, QString& output);
|
bool reset(const QString& folder, const QString& commit, GitResetStrategy strategy, QString& output);
|
||||||
|
|
||||||
bool isValid();
|
bool isValid();
|
||||||
|
|
|
@ -30,24 +30,24 @@ bool GitRepository::hasRepository(QString& currentBranch)
|
||||||
return mInRepository;
|
return mInRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::add(const QString &path)
|
bool GitRepository::add(const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
mManager->add(mFolder,path);
|
return mManager->add(mFolder,path, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::remove(const QString &path)
|
bool GitRepository::remove(const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
mManager->remove(mFolder,path);
|
return mManager->remove(mFolder,path, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::rename(const QString &oldName, const QString &newName)
|
bool GitRepository::rename(const QString &oldName, const QString &newName, QString& output)
|
||||||
{
|
{
|
||||||
mManager->rename(mFolder, oldName, newName);
|
return mManager->rename(mFolder, oldName, newName,output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::restore(const QString &path)
|
bool GitRepository::restore(const QString &path, QString& output)
|
||||||
{
|
{
|
||||||
mManager->restore(mFolder, path);
|
return mManager->restore(mFolder, path, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSet<QString> GitRepository::listFiles(bool refresh)
|
QSet<QString> GitRepository::listFiles(bool refresh)
|
||||||
|
@ -57,19 +57,19 @@ QSet<QString> GitRepository::listFiles(bool refresh)
|
||||||
return mFilesInRepositories;
|
return mFilesInRepositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::clone(const QString &url)
|
bool GitRepository::clone(const QString &url, QString& output)
|
||||||
{
|
{
|
||||||
mManager->clone(mFolder,url);
|
return mManager->clone(mFolder,url, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::commit(const QString &message, bool autoStage)
|
bool GitRepository::commit(const QString &message, QString& output, bool autoStage)
|
||||||
{
|
{
|
||||||
mManager->commit(mRealFolder, message, autoStage);
|
return mManager->commit(mRealFolder, message, autoStage, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::revert()
|
bool GitRepository::revert(QString& output)
|
||||||
{
|
{
|
||||||
mManager->revert(mRealFolder);
|
return mManager->revert(mRealFolder, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitRepository::setFolder(const QString &newFolder)
|
void GitRepository::setFolder(const QString &newFolder)
|
||||||
|
|
|
@ -54,15 +54,15 @@ public:
|
||||||
return !mConflicts.isEmpty();
|
return !mConflicts.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const QString& path);
|
bool add(const QString& path, QString& output);
|
||||||
void remove(const QString& path);
|
bool remove(const QString& path, QString& output);
|
||||||
void rename(const QString& oldName, const QString& newName);
|
bool rename(const QString& oldName, const QString& newName, QString& output);
|
||||||
void restore(const QString& path);
|
bool restore(const QString& path, QString& output);
|
||||||
QSet<QString> listFiles(bool refresh);
|
QSet<QString> listFiles(bool refresh);
|
||||||
|
|
||||||
void clone(const QString& url);
|
bool clone(const QString& url, QString& output);
|
||||||
void commit(const QString& message, bool autoStage=true);
|
bool commit(const QString& message, QString& output, bool autoStage=true);
|
||||||
void revert();
|
bool revert(QString& output);
|
||||||
|
|
||||||
|
|
||||||
void setFolder(const QString &newFolder);
|
void setFolder(const QString &newFolder);
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
#include "gituserconfigdialog.h"
|
||||||
|
#include "ui_gituserconfigdialog.h"
|
||||||
|
#include "gitmanager.h"
|
||||||
|
#include "../widgets/infomessagebox.h"
|
||||||
|
|
||||||
|
GitUserConfigDialog::GitUserConfigDialog(const QString& folder, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::GitUserConfigDialog),
|
||||||
|
mFolder(folder)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
GitManager manager;
|
||||||
|
ui->txtUserName->setText(manager.getUserName(folder));
|
||||||
|
ui->txtUserEmail->setText(manager.getUserEmail(folder));
|
||||||
|
checkInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
GitUserConfigDialog::~GitUserConfigDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitUserConfigDialog::checkInfo()
|
||||||
|
{
|
||||||
|
ui->btnOk->setEnabled(!ui->txtUserEmail->text().isEmpty()
|
||||||
|
&& !ui->txtUserName->text().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitUserConfigDialog::on_btnOk_clicked()
|
||||||
|
{
|
||||||
|
GitManager manager;
|
||||||
|
QString output;
|
||||||
|
if (!manager.setUserName(mFolder, ui->txtUserName->text(),output)) {
|
||||||
|
InfoMessageBox infoBox;
|
||||||
|
infoBox.showMessage(output);
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
if (!manager.setUserEmail(mFolder, ui->txtUserEmail->text(),output)) {
|
||||||
|
InfoMessageBox infoBox;
|
||||||
|
infoBox.showMessage(output);
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GitUserConfigDialog::on_btnCancel_clicked()
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitUserConfigDialog::closeEvent(QCloseEvent * /*event*/)
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GitUserConfigDialog::on_txtUserName_textChanged(const QString &/*arg1*/)
|
||||||
|
{
|
||||||
|
checkInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GitUserConfigDialog::on_txtUserEmail_textChanged(const QString &/*arg1*/)
|
||||||
|
{
|
||||||
|
checkInfo();
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#ifndef GITUSERCONFIGDIALOG_H
|
||||||
|
#define GITUSERCONFIGDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class GitUserConfigDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class GitUserConfigDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit GitUserConfigDialog(const QString& folder, QWidget *parent = nullptr);
|
||||||
|
~GitUserConfigDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::GitUserConfigDialog *ui;
|
||||||
|
QString mFolder;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void checkInfo();
|
||||||
|
private slots:
|
||||||
|
void on_btnOk_clicked();
|
||||||
|
void on_btnCancel_clicked();
|
||||||
|
void on_txtUserName_textChanged(const QString &arg1);
|
||||||
|
void on_txtUserEmail_textChanged(const QString &arg1);
|
||||||
|
|
||||||
|
// QWidget interface
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GITUSERCONFIGDIALOG_H
|
|
@ -0,0 +1,97 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>GitUserConfigDialog</class>
|
||||||
|
<widget class="QDialog" name="GitUserConfigDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>429</width>
|
||||||
|
<height>299</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Fill User Info</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLineEdit" name="txtUserEmail"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>User Email:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" rowspan="2">
|
||||||
|
<widget class="QLineEdit" name="txtUserName"/>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QWidget" name="widget" native="true">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<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>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>User Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Git needs the following info to commit:</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue