Git: Filter out commits according to active remote

... in the Push to Gerrit dialog.

Fixes: QTCREATORBUG-24436
Change-Id: I2f1ab49d9fbeb09ffb66de23d34a2facd53cb725
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2020-08-09 18:44:12 +03:00
committed by Orgad Shaneh
parent bafc8381c6
commit 354f628052
3 changed files with 17 additions and 2 deletions

View File

@@ -66,6 +66,8 @@ protected:
QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
{
const QString earliestCommit = m_ui->commitView->earliestCommit();
if (earliestCommit.isEmpty())
return {};
QString output;
QString error;
@@ -233,6 +235,13 @@ void GerritPushDialog::onRemoteChanged(bool force)
{
setRemoteBranches();
const QString version = m_ui->remoteComboBox->currentServer().version;
const QString remote = m_ui->remoteComboBox->currentRemoteName();
m_ui->commitView->setExcludedRemote(remote);
const QString branch = m_ui->localBranchComboBox->itemText(m_ui->localBranchComboBox->currentIndex());
m_hasLocalCommits = m_ui->commitView->init(m_workingDir, branch, LogChangeWidget::Silent);
validate();
const bool supportsWip = versionSupportsWip(version);
if (!force && supportsWip == m_currentSupportsWip)
return;

View File

@@ -183,8 +183,12 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
QStringList arguments;
arguments << "--max-count=1000" << "--format=%h:%s %d";
arguments << (commit.isEmpty() ? "HEAD" : commit);
if (!(flags & IncludeRemotes))
arguments << "--not" << "--remotes";
if (!(flags & IncludeRemotes)) {
QString remotesFlag("--remotes");
if (!m_excludedRemote.isEmpty())
remotesFlag += '=' + m_excludedRemote;
arguments << "--not" << remotesFlag;
}
arguments << "--";
QString output;
if (!GitClient::instance()->synchronousLog(

View File

@@ -67,6 +67,7 @@ public:
int commitIndex() const;
QString earliestCommit() const;
void setItemDelegate(QAbstractItemDelegate *delegate);
void setExcludedRemote(const QString &remote) { m_excludedRemote = remote; }
signals:
void commitActivated(const QString &commit);
@@ -80,6 +81,7 @@ private:
LogChangeModel *m_model;
bool m_hasCustomDelegate;
QString m_excludedRemote;
};
class LogChangeDialog : public QDialog