forked from qt-creator/qt-creator
VCS[git]: Add menu option for git amend.
Task-number: QTCREATORBUG-1642
This commit is contained in:
@@ -142,6 +142,7 @@ struct SubmitEditorWidgetPrivate
|
|||||||
bool m_filesChecked;
|
bool m_filesChecked;
|
||||||
int m_fileNameColumn;
|
int m_fileNameColumn;
|
||||||
int m_activatedRow;
|
int m_activatedRow;
|
||||||
|
bool m_emptyFileListEnabled;
|
||||||
|
|
||||||
QList<AdditionalContextMenuAction> descriptionEditContextMenuActions;
|
QList<AdditionalContextMenuAction> descriptionEditContextMenuActions;
|
||||||
QVBoxLayout *m_fieldLayout;
|
QVBoxLayout *m_fieldLayout;
|
||||||
@@ -154,6 +155,7 @@ SubmitEditorWidgetPrivate::SubmitEditorWidgetPrivate() :
|
|||||||
m_filesChecked(false),
|
m_filesChecked(false),
|
||||||
m_fileNameColumn(1),
|
m_fileNameColumn(1),
|
||||||
m_activatedRow(-1),
|
m_activatedRow(-1),
|
||||||
|
m_emptyFileListEnabled(false),
|
||||||
m_fieldLayout(0),
|
m_fieldLayout(0),
|
||||||
m_lineWidth(defaultLineWidth)
|
m_lineWidth(defaultLineWidth)
|
||||||
{
|
{
|
||||||
@@ -446,7 +448,7 @@ void SubmitEditorWidget::updateActions()
|
|||||||
void SubmitEditorWidget::updateSubmitAction()
|
void SubmitEditorWidget::updateSubmitAction()
|
||||||
{
|
{
|
||||||
const unsigned checkedCount = checkedFilesCount();
|
const unsigned checkedCount = checkedFilesCount();
|
||||||
const bool newFilesCheckedState = checkedCount;
|
const bool newFilesCheckedState = m_d->m_emptyFileListEnabled || checkedCount > 0;
|
||||||
// Emit signal to update action
|
// Emit signal to update action
|
||||||
if (m_d->m_filesChecked != newFilesCheckedState) {
|
if (m_d->m_filesChecked != newFilesCheckedState) {
|
||||||
m_d->m_filesChecked = newFilesCheckedState;
|
m_d->m_filesChecked = newFilesCheckedState;
|
||||||
@@ -581,6 +583,19 @@ void SubmitEditorWidget::fileListCustomContextMenuRequested(const QPoint & pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SubmitEditorWidget::isEmptyFileListEnabled() const
|
||||||
|
{
|
||||||
|
return m_d->m_emptyFileListEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SubmitEditorWidget::setEmptyFileListEnabled(bool e)
|
||||||
|
{
|
||||||
|
if (e != m_d->m_emptyFileListEnabled) {
|
||||||
|
m_d->m_emptyFileListEnabled = e;
|
||||||
|
updateSubmitAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
#include "submiteditorwidget.moc"
|
#include "submiteditorwidget.moc"
|
||||||
|
@@ -76,6 +76,8 @@ class QTCREATOR_UTILS_EXPORT SubmitEditorWidget : public QWidget
|
|||||||
Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
|
Q_PROPERTY(QAbstractItemView::SelectionMode fileListSelectionMode READ fileListSelectionMode WRITE setFileListSelectionMode DESIGNABLE true)
|
||||||
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
|
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
|
||||||
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
|
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
|
||||||
|
Q_PROPERTY(bool emptyFileListEnabled READ isEmptyFileListEnabled WRITE setEmptyFileListEnabled DESIGNABLE true)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SubmitEditorWidget(QWidget *parent = 0);
|
explicit SubmitEditorWidget(QWidget *parent = 0);
|
||||||
virtual ~SubmitEditorWidget();
|
virtual ~SubmitEditorWidget();
|
||||||
@@ -91,6 +93,10 @@ public:
|
|||||||
QString descriptionText() const;
|
QString descriptionText() const;
|
||||||
void setDescriptionText(const QString &text);
|
void setDescriptionText(const QString &text);
|
||||||
|
|
||||||
|
// 'Commit' action enabled despite empty file list
|
||||||
|
bool isEmptyFileListEnabled() const;
|
||||||
|
void setEmptyFileListEnabled(bool e);
|
||||||
|
|
||||||
int fileNameColumn() const;
|
int fileNameColumn() const;
|
||||||
void setFileNameColumn(int c);
|
void setFileNameColumn(int c);
|
||||||
|
|
||||||
|
@@ -82,6 +82,7 @@ void CommitData::clear()
|
|||||||
{
|
{
|
||||||
panelInfo.clear();
|
panelInfo.clear();
|
||||||
panelData.clear();
|
panelData.clear();
|
||||||
|
amendSHA1.clear();
|
||||||
|
|
||||||
stagedFiles.clear();
|
stagedFiles.clear();
|
||||||
unstagedFiles.clear();
|
unstagedFiles.clear();
|
||||||
|
@@ -80,6 +80,7 @@ struct CommitData
|
|||||||
QStringList stagedFileNames(const QString &stateFilter = QString()) const;
|
QStringList stagedFileNames(const QString &stateFilter = QString()) const;
|
||||||
QStringList unstagedFileNames(const QString &stateFilter = QString()) const;
|
QStringList unstagedFileNames(const QString &stateFilter = QString()) const;
|
||||||
|
|
||||||
|
QString amendSHA1;
|
||||||
GitSubmitEditorPanelInfo panelInfo;
|
GitSubmitEditorPanelInfo panelInfo;
|
||||||
GitSubmitEditorPanelData panelData;
|
GitSubmitEditorPanelData panelData;
|
||||||
|
|
||||||
|
@@ -1336,14 +1336,15 @@ void GitClient::launchGitK(const QString &workingDirectory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool GitClient::getCommitData(const QString &workingDirectory,
|
bool GitClient::getCommitData(const QString &workingDirectory,
|
||||||
|
bool amend,
|
||||||
QString *commitTemplate,
|
QString *commitTemplate,
|
||||||
CommitData *d,
|
CommitData *commitData,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (Git::Constants::debug)
|
if (Git::Constants::debug)
|
||||||
qDebug() << Q_FUNC_INFO << workingDirectory;
|
qDebug() << Q_FUNC_INFO << workingDirectory;
|
||||||
|
|
||||||
d->clear();
|
commitData->clear();
|
||||||
|
|
||||||
// Find repo
|
// Find repo
|
||||||
const QString repoDirectory = GitClient::findRepositoryForDirectory(workingDirectory);
|
const QString repoDirectory = GitClient::findRepositoryForDirectory(workingDirectory);
|
||||||
@@ -1352,7 +1353,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->panelInfo.repository = repoDirectory;
|
commitData->panelInfo.repository = repoDirectory;
|
||||||
|
|
||||||
QDir gitDir(repoDirectory);
|
QDir gitDir(repoDirectory);
|
||||||
if (!gitDir.cd(QLatin1String(kGitDirectoryC))) {
|
if (!gitDir.cd(QLatin1String(kGitDirectoryC))) {
|
||||||
@@ -1365,13 +1366,14 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
if (QFileInfo(descriptionFile).isFile()) {
|
if (QFileInfo(descriptionFile).isFile()) {
|
||||||
QFile file(descriptionFile);
|
QFile file(descriptionFile);
|
||||||
if (file.open(QIODevice::ReadOnly|QIODevice::Text))
|
if (file.open(QIODevice::ReadOnly|QIODevice::Text))
|
||||||
d->panelInfo.description = commandOutputFromLocal8Bit(file.readAll()).trimmed();
|
commitData->panelInfo.description = commandOutputFromLocal8Bit(file.readAll()).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run status. Note that it has exitcode 1 if there are no added files.
|
// Run status. Note that it has exitcode 1 if there are no added files.
|
||||||
bool onBranch;
|
bool onBranch;
|
||||||
QString output;
|
QString output;
|
||||||
switch (gitStatus(repoDirectory, true, &output, errorMessage, &onBranch)) {
|
const StatusResult status = gitStatus(repoDirectory, true, &output, errorMessage, &onBranch);
|
||||||
|
switch (status) {
|
||||||
case StatusChanged:
|
case StatusChanged:
|
||||||
if (!onBranch) {
|
if (!onBranch) {
|
||||||
*errorMessage = tr("You did not checkout a branch.");
|
*errorMessage = tr("You did not checkout a branch.");
|
||||||
@@ -1379,6 +1381,8 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StatusUnchanged:
|
case StatusUnchanged:
|
||||||
|
if (amend)
|
||||||
|
break;
|
||||||
*errorMessage = msgNoChangedFiles();
|
*errorMessage = msgNoChangedFiles();
|
||||||
return false;
|
return false;
|
||||||
case StatusFailed:
|
case StatusFailed:
|
||||||
@@ -1403,42 +1407,71 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
|||||||
// #
|
// #
|
||||||
// # list of files...
|
// # list of files...
|
||||||
|
|
||||||
if (!d->parseFilesFromStatus(output)) {
|
if (status != StatusUnchanged) {
|
||||||
*errorMessage = msgParseFilesFailed();
|
if (!commitData->parseFilesFromStatus(output)) {
|
||||||
return false;
|
*errorMessage = msgParseFilesFailed();
|
||||||
}
|
return false;
|
||||||
// Filter out untracked files that are not part of the project
|
}
|
||||||
VCSBase::VCSBaseSubmitEditor::filterUntrackedFilesOfProject(repoDirectory, &d->untrackedFiles);
|
// Filter out untracked files that are not part of the project
|
||||||
if (d->filesEmpty()) {
|
VCSBase::VCSBaseSubmitEditor::filterUntrackedFilesOfProject(repoDirectory, &commitData->untrackedFiles);
|
||||||
*errorMessage = msgNoChangedFiles();
|
if (commitData->filesEmpty()) {
|
||||||
return false;
|
*errorMessage = msgNoChangedFiles();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->panelData.author = readConfigValue(workingDirectory, QLatin1String("user.name"));
|
commitData->panelData.author = readConfigValue(workingDirectory, QLatin1String("user.name"));
|
||||||
d->panelData.email = readConfigValue(workingDirectory, QLatin1String("user.email"));
|
commitData->panelData.email = readConfigValue(workingDirectory, QLatin1String("user.email"));
|
||||||
|
|
||||||
// Get the commit template
|
// Get the commit template or the last commit message
|
||||||
QString templateFilename = readConfigValue(workingDirectory, QLatin1String("commit.template"));
|
if (amend) {
|
||||||
if (!templateFilename.isEmpty()) {
|
// Amend: get last commit data as "SHA1@message". TODO: Figure out codec.
|
||||||
// Make relative to repository
|
QStringList args(QLatin1String("log"));
|
||||||
const QFileInfo templateFileInfo(templateFilename);
|
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:%h@%B");
|
||||||
if (templateFileInfo.isRelative())
|
const Utils::SynchronousProcessResponse sp = synchronousGit(repoDirectory, args);
|
||||||
templateFilename = repoDirectory + QLatin1Char('/') + templateFilename;
|
if (sp.result != Utils::SynchronousProcessResponse::Finished) {
|
||||||
QFile templateFile(templateFilename);
|
*errorMessage = tr("Unable to retrieve the last commit data from %1.").arg(repoDirectory);
|
||||||
if (templateFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
return false;
|
||||||
*commitTemplate = QString::fromLocal8Bit(templateFile.readAll());
|
}
|
||||||
} else {
|
const int separatorPos = sp.stdOut.indexOf(QLatin1Char('@'));
|
||||||
qWarning("Unable to read commit template %s: %s",
|
QTC_ASSERT(separatorPos != -1, return false)
|
||||||
qPrintable(templateFilename),
|
commitData->amendSHA1= sp.stdOut.left(separatorPos);
|
||||||
qPrintable(templateFile.errorString()));
|
*commitTemplate = sp.stdOut.mid(separatorPos + 1);
|
||||||
|
} else {
|
||||||
|
// Commit: Get the commit template
|
||||||
|
QString templateFilename = readConfigValue(workingDirectory, QLatin1String("commit.template"));
|
||||||
|
if (!templateFilename.isEmpty()) {
|
||||||
|
// Make relative to repository
|
||||||
|
const QFileInfo templateFileInfo(templateFilename);
|
||||||
|
if (templateFileInfo.isRelative())
|
||||||
|
templateFilename = repoDirectory + QLatin1Char('/') + templateFilename;
|
||||||
|
QFile templateFile(templateFilename);
|
||||||
|
if (templateFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
||||||
|
*commitTemplate = QString::fromLocal8Bit(templateFile.readAll());
|
||||||
|
} else {
|
||||||
|
qWarning("Unable to read commit template %s: %s",
|
||||||
|
qPrintable(templateFilename),
|
||||||
|
qPrintable(templateFile.errorString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log message for commits/amended commits to go to output window
|
||||||
|
static inline QString msgCommitted(const QString &amendSHA1, int fileCount)
|
||||||
|
{
|
||||||
|
if (amendSHA1.isEmpty())
|
||||||
|
return GitClient::tr("Committed %n file(s).\n", 0, fileCount);
|
||||||
|
if (fileCount)
|
||||||
|
return GitClient::tr("Amended %1 (%n file(s)).\n", 0, fileCount).arg(amendSHA1);
|
||||||
|
return GitClient::tr("Amended %1.").arg(amendSHA1);
|
||||||
|
}
|
||||||
|
|
||||||
// addAndCommit:
|
// addAndCommit:
|
||||||
bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
||||||
const GitSubmitEditorPanelData &data,
|
const GitSubmitEditorPanelData &data,
|
||||||
|
const QString &amendSHA1,
|
||||||
const QString &messageFile,
|
const QString &messageFile,
|
||||||
const QStringList &checkedFiles,
|
const QStringList &checkedFiles,
|
||||||
const QStringList &origCommitFiles,
|
const QStringList &origCommitFiles,
|
||||||
@@ -1447,6 +1480,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
|||||||
if (Git::Constants::debug)
|
if (Git::Constants::debug)
|
||||||
qDebug() << "GitClient::addAndCommit:" << repositoryDirectory << checkedFiles << origCommitFiles;
|
qDebug() << "GitClient::addAndCommit:" << repositoryDirectory << checkedFiles << origCommitFiles;
|
||||||
const QString renamedSeparator = QLatin1String(" -> ");
|
const QString renamedSeparator = QLatin1String(" -> ");
|
||||||
|
const bool amend = !amendSHA1.isEmpty();
|
||||||
|
|
||||||
// Do we need to reset any files that had been added before
|
// Do we need to reset any files that had been added before
|
||||||
// (did the user uncheck any previously added files)
|
// (did the user uncheck any previously added files)
|
||||||
@@ -1483,7 +1517,8 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
|||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("commit")
|
args << QLatin1String("commit")
|
||||||
<< QLatin1String("-F") << QDir::toNativeSeparators(messageFile);
|
<< QLatin1String("-F") << QDir::toNativeSeparators(messageFile);
|
||||||
|
if (amend)
|
||||||
|
args << QLatin1String("--amend");
|
||||||
const QString &authorString = data.authorString();
|
const QString &authorString = data.authorString();
|
||||||
if (!authorString.isEmpty())
|
if (!authorString.isEmpty())
|
||||||
args << QLatin1String("--author") << authorString;
|
args << QLatin1String("--author") << authorString;
|
||||||
@@ -1492,7 +1527,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
|||||||
QByteArray errorText;
|
QByteArray errorText;
|
||||||
const bool rc = fullySynchronousGit(repositoryDirectory, args, &outputText, &errorText);
|
const bool rc = fullySynchronousGit(repositoryDirectory, args, &outputText, &errorText);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
outputWindow()->append(tr("Committed %n file(s).\n", 0, checkedFiles.size()));
|
outputWindow()->append(msgCommitted(amendSHA1, checkedFiles.size()));
|
||||||
} else {
|
} else {
|
||||||
outputWindow()->appendError(tr("Unable to commit %n file(s): %1\n", 0, checkedFiles.size()).arg(commandOutputFromLocal8Bit(errorText)));
|
outputWindow()->appendError(tr("Unable to commit %n file(s): %1\n", 0, checkedFiles.size()).arg(commandOutputFromLocal8Bit(errorText)));
|
||||||
}
|
}
|
||||||
|
@@ -185,13 +185,13 @@ public:
|
|||||||
StashResult ensureStash(const QString &workingDirectory, QString *errorMessage);
|
StashResult ensureStash(const QString &workingDirectory, QString *errorMessage);
|
||||||
StashResult ensureStash(const QString &workingDirectory);
|
StashResult ensureStash(const QString &workingDirectory);
|
||||||
|
|
||||||
bool getCommitData(const QString &workingDirectory,
|
bool getCommitData(const QString &workingDirectory, bool amend,
|
||||||
QString *commitTemplate,
|
QString *commitTemplate, CommitData *commitData,
|
||||||
CommitData *d,
|
|
||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
|
|
||||||
bool addAndCommit(const QString &workingDirectory,
|
bool addAndCommit(const QString &workingDirectory,
|
||||||
const GitSubmitEditorPanelData &data,
|
const GitSubmitEditorPanelData &data,
|
||||||
|
const QString &amendSHA1,
|
||||||
const QString &messageFile,
|
const QString &messageFile,
|
||||||
const QStringList &checkedFiles,
|
const QStringList &checkedFiles,
|
||||||
const QStringList &origCommitFiles,
|
const QStringList &origCommitFiles,
|
||||||
|
@@ -451,6 +451,10 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
globalcontext, true, SLOT(startCommit()));
|
globalcontext, true, SLOT(startCommit()));
|
||||||
actionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+C")));
|
actionCommand.second->setDefaultKeySequence(QKeySequence(tr("Alt+G,Alt+C")));
|
||||||
|
|
||||||
|
createRepositoryAction(actionManager, gitContainer,
|
||||||
|
tr("Amend Last Commit..."), QLatin1String("Git.AmendCommit"),
|
||||||
|
globalcontext, true, SLOT(startAmendCommit()));
|
||||||
|
|
||||||
actionCommand = createRepositoryAction(actionManager, gitContainer,
|
actionCommand = createRepositoryAction(actionManager, gitContainer,
|
||||||
tr("Push"), QLatin1String("Git.Push"),
|
tr("Push"), QLatin1String("Git.Push"),
|
||||||
globalcontext, true, SLOT(push()));
|
globalcontext, true, SLOT(push()));
|
||||||
@@ -610,8 +614,19 @@ void GitPlugin::unstageFile()
|
|||||||
m_gitClient->synchronousReset(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
m_gitClient->synchronousReset(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GitPlugin::startAmendCommit()
|
||||||
|
{
|
||||||
|
startCommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
void GitPlugin::startCommit()
|
void GitPlugin::startCommit()
|
||||||
{
|
{
|
||||||
|
startCommit(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GitPlugin::startCommit(bool amend)
|
||||||
|
{
|
||||||
|
|
||||||
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
|
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
|
||||||
return;
|
return;
|
||||||
if (isCommitEditorOpen()) {
|
if (isCommitEditorOpen()) {
|
||||||
@@ -624,7 +639,7 @@ void GitPlugin::startCommit()
|
|||||||
|
|
||||||
QString errorMessage, commitTemplate;
|
QString errorMessage, commitTemplate;
|
||||||
CommitData data;
|
CommitData data;
|
||||||
if (!m_gitClient->getCommitData(state.topLevel(), &commitTemplate, &data, &errorMessage)) {
|
if (!m_gitClient->getCommitData(state.topLevel(), amend, &commitTemplate, &data, &errorMessage)) {
|
||||||
VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage);
|
VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -632,6 +647,7 @@ void GitPlugin::startCommit()
|
|||||||
// Store repository for diff and the original list of
|
// Store repository for diff and the original list of
|
||||||
// files to be able to unstage files the user unchecks
|
// files to be able to unstage files the user unchecks
|
||||||
m_submitRepository = data.panelInfo.repository;
|
m_submitRepository = data.panelInfo.repository;
|
||||||
|
m_commitAmendSHA1 = data.amendSHA1;
|
||||||
m_submitOrigCommitFiles = data.stagedFileNames();
|
m_submitOrigCommitFiles = data.stagedFileNames();
|
||||||
m_submitOrigDeleteFiles = data.stagedFileNames("deleted");
|
m_submitOrigDeleteFiles = data.stagedFileNames("deleted");
|
||||||
|
|
||||||
@@ -651,10 +667,10 @@ void GitPlugin::startCommit()
|
|||||||
// Keep the file alive, else it removes self and forgets
|
// Keep the file alive, else it removes self and forgets
|
||||||
// its name
|
// its name
|
||||||
changeTmpFile.close();
|
changeTmpFile.close();
|
||||||
openSubmitEditor(m_commitMessageFileName, data);
|
openSubmitEditor(m_commitMessageFileName, data, amend);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd)
|
Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend)
|
||||||
{
|
{
|
||||||
Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_ID));
|
Core::IEditor *editor = m_core->editorManager()->openEditor(fileName, QLatin1String(Constants::GITSUBMITEDITOR_ID));
|
||||||
if (Git::Constants::debug)
|
if (Git::Constants::debug)
|
||||||
@@ -667,6 +683,10 @@ Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const Commit
|
|||||||
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
|
submitEditor->registerActions(m_undoAction, m_redoAction, m_submitCurrentAction, m_diffSelectedFilesAction);
|
||||||
submitEditor->setCommitData(cd);
|
submitEditor->setCommitData(cd);
|
||||||
submitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
|
submitEditor->setCheckScriptWorkingDirectory(m_submitRepository);
|
||||||
|
const QString title = amend ? tr("Amend %1").arg(cd.amendSHA1) : tr("Git Commit");
|
||||||
|
submitEditor->setDisplayName(title);
|
||||||
|
if (amend) // Allow for just correcting the message
|
||||||
|
submitEditor->setEmptyFileListEnabled(true);
|
||||||
connect(submitEditor, SIGNAL(diff(QStringList,QStringList)), this, SLOT(submitEditorDiff(QStringList,QStringList)));
|
connect(submitEditor, SIGNAL(diff(QStringList,QStringList)), this, SLOT(submitEditorDiff(QStringList,QStringList)));
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
@@ -721,7 +741,7 @@ bool GitPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEdi
|
|||||||
if (Git::Constants::debug)
|
if (Git::Constants::debug)
|
||||||
qDebug() << Q_FUNC_INFO << fileList;
|
qDebug() << Q_FUNC_INFO << fileList;
|
||||||
bool closeEditor = true;
|
bool closeEditor = true;
|
||||||
if (!fileList.empty()) {
|
if (!fileList.empty() || !m_commitAmendSHA1.isEmpty()) {
|
||||||
// get message & commit
|
// get message & commit
|
||||||
m_core->fileManager()->blockFileChange(fileIFace);
|
m_core->fileManager()->blockFileChange(fileIFace);
|
||||||
fileIFace->save();
|
fileIFace->save();
|
||||||
@@ -729,6 +749,7 @@ bool GitPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEdi
|
|||||||
|
|
||||||
closeEditor = m_gitClient->addAndCommit(m_submitRepository,
|
closeEditor = m_gitClient->addAndCommit(m_submitRepository,
|
||||||
editor->panelData(),
|
editor->panelData(),
|
||||||
|
m_commitAmendSHA1,
|
||||||
m_commitMessageFileName,
|
m_commitMessageFileName,
|
||||||
fileList,
|
fileList,
|
||||||
m_submitOrigCommitFiles,
|
m_submitOrigCommitFiles,
|
||||||
|
@@ -122,6 +122,7 @@ private slots:
|
|||||||
|
|
||||||
void showCommit();
|
void showCommit();
|
||||||
void startCommit();
|
void startCommit();
|
||||||
|
void startAmendCommit();
|
||||||
void stash();
|
void stash();
|
||||||
void stashSnapshot();
|
void stashSnapshot();
|
||||||
void branchList();
|
void branchList();
|
||||||
@@ -170,10 +171,11 @@ private:
|
|||||||
bool addToLocator, GitClientMemberFunc);
|
bool addToLocator, GitClientMemberFunc);
|
||||||
|
|
||||||
bool isCommitEditorOpen() const;
|
bool isCommitEditorOpen() const;
|
||||||
Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd);
|
Core::IEditor *openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend);
|
||||||
void cleanCommitMessageFile();
|
void cleanCommitMessageFile();
|
||||||
void cleanRepository(const QString &directory);
|
void cleanRepository(const QString &directory);
|
||||||
void applyPatch(const QString &workingDirectory, QString file = QString());
|
void applyPatch(const QString &workingDirectory, QString file = QString());
|
||||||
|
void startCommit(bool amend);
|
||||||
|
|
||||||
static GitPlugin *m_instance;
|
static GitPlugin *m_instance;
|
||||||
Core::ICore *m_core;
|
Core::ICore *m_core;
|
||||||
@@ -201,6 +203,7 @@ private:
|
|||||||
QStringList m_submitOrigCommitFiles;
|
QStringList m_submitOrigCommitFiles;
|
||||||
QStringList m_submitOrigDeleteFiles;
|
QStringList m_submitOrigDeleteFiles;
|
||||||
QString m_commitMessageFileName;
|
QString m_commitMessageFileName;
|
||||||
|
QString m_commitAmendSHA1;
|
||||||
bool m_submitActionTriggered;
|
bool m_submitActionTriggered;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -52,7 +52,6 @@ GitSubmitEditor::GitSubmitEditor(const VCSBase::VCSBaseSubmitEditorParameters *p
|
|||||||
VCSBaseSubmitEditor(parameters, new GitSubmitEditorWidget(parent)),
|
VCSBaseSubmitEditor(parameters, new GitSubmitEditorWidget(parent)),
|
||||||
m_model(0)
|
m_model(0)
|
||||||
{
|
{
|
||||||
setDisplayName(tr("Git Commit"));
|
|
||||||
connect(this, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotDiffSelected(QStringList)));
|
connect(this, SIGNAL(diffSelectedFiles(QStringList)), this, SLOT(slotDiffSelected(QStringList)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -230,6 +230,7 @@ void VCSBaseSubmitEditor::unregisterActions(QAction *editorUndoAction, QAction
|
|||||||
m_d->m_widget->unregisterActions(editorUndoAction, editorRedoAction, submitAction, diffAction);
|
m_d->m_widget->unregisterActions(editorUndoAction, editorRedoAction, submitAction, diffAction);
|
||||||
m_d->m_diffAction = m_d->m_submitAction = 0;
|
m_d->m_diffAction = m_d->m_submitAction = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VCSBaseSubmitEditor::fileNameColumn() const
|
int VCSBaseSubmitEditor::fileNameColumn() const
|
||||||
{
|
{
|
||||||
return m_d->m_widget->fileNameColumn();
|
return m_d->m_widget->fileNameColumn();
|
||||||
@@ -250,6 +251,16 @@ void VCSBaseSubmitEditor::setFileListSelectionMode(QAbstractItemView::SelectionM
|
|||||||
m_d->m_widget->setFileListSelectionMode(sm);
|
m_d->m_widget->setFileListSelectionMode(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VCSBaseSubmitEditor::isEmptyFileListEnabled() const
|
||||||
|
{
|
||||||
|
return m_d->m_widget->isEmptyFileListEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VCSBaseSubmitEditor::setEmptyFileListEnabled(bool e)
|
||||||
|
{
|
||||||
|
m_d->m_widget->setEmptyFileListEnabled(e);
|
||||||
|
}
|
||||||
|
|
||||||
bool VCSBaseSubmitEditor::lineWrap() const
|
bool VCSBaseSubmitEditor::lineWrap() const
|
||||||
{
|
{
|
||||||
return m_d->m_widget->lineWrap();
|
return m_d->m_widget->lineWrap();
|
||||||
|
@@ -90,6 +90,7 @@ class VCSBASE_EXPORT VCSBaseSubmitEditor : public Core::IEditor
|
|||||||
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
|
Q_PROPERTY(bool lineWrap READ lineWrap WRITE setLineWrap DESIGNABLE true)
|
||||||
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
|
Q_PROPERTY(int lineWrapWidth READ lineWrapWidth WRITE setLineWrapWidth DESIGNABLE true)
|
||||||
Q_PROPERTY(QString checkScriptWorkingDirectory READ checkScriptWorkingDirectory WRITE setCheckScriptWorkingDirectory DESIGNABLE true)
|
Q_PROPERTY(QString checkScriptWorkingDirectory READ checkScriptWorkingDirectory WRITE setCheckScriptWorkingDirectory DESIGNABLE true)
|
||||||
|
Q_PROPERTY(bool emptyFileListEnabled READ isEmptyFileListEnabled WRITE setEmptyFileListEnabled DESIGNABLE true)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
|
explicit VCSBaseSubmitEditor(const VCSBaseSubmitEditorParameters *parameters,
|
||||||
@@ -122,6 +123,10 @@ public:
|
|||||||
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
QAbstractItemView::SelectionMode fileListSelectionMode() const;
|
||||||
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
void setFileListSelectionMode(QAbstractItemView::SelectionMode sm);
|
||||||
|
|
||||||
|
// 'Commit' action enabled despite empty file list
|
||||||
|
bool isEmptyFileListEnabled() const;
|
||||||
|
void setEmptyFileListEnabled(bool e);
|
||||||
|
|
||||||
bool lineWrap() const;
|
bool lineWrap() const;
|
||||||
void setLineWrap(bool);
|
void setLineWrap(bool);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user