Gerrit: Move push target logic to GerritPushDialog

Less indirection + will simplify new private/wip flags.

Change-Id: If8c4072b6456b4044d83ef17e130e0360a1d05f8
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2017-10-14 23:40:05 +03:00
committed by Orgad Shaneh
parent 7a04014f9f
commit c19c2551fb
3 changed files with 23 additions and 25 deletions

View File

@@ -328,25 +328,7 @@ void GerritPlugin::push(const QString &topLevel)
dialog.storeTopic();
m_reviewers = dialog.reviewers();
QString target = dialog.selectedCommit();
if (target.isEmpty())
target = "HEAD";
target += ":refs/" + dialog.selectedPushType() +
'/' + dialog.selectedRemoteBranchName();
const QString topic = dialog.selectedTopic();
if (!topic.isEmpty())
target += '/' + topic;
QStringList options;
const QStringList reviewers = m_reviewers.split(',', QString::SkipEmptyParts);
for (const QString &reviewer : reviewers)
options << "r=" + reviewer;
if (!options.isEmpty())
target += '%' + options.join(',');
GitPlugin::client()->push(topLevel, {dialog.selectedRemoteName(), target});
GitPlugin::client()->push(topLevel, {dialog.selectedRemoteName(), dialog.pushTarget()});
}
// Open or raise the Gerrit dialog window.

View File

@@ -214,6 +214,27 @@ QString GerritPushDialog::initErrorMessage() const
return m_initErrorMessage;
}
QString GerritPushDialog::pushTarget() const
{
QString target = selectedCommit();
if (target.isEmpty())
target = "HEAD";
target += ":refs/" + QLatin1String(m_ui->draftCheckBox->isChecked() ? "drafts" : "for") +
'/' + selectedRemoteBranchName();
const QString topic = selectedTopic();
if (!topic.isEmpty())
target += '/' + topic;
QStringList options;
const QStringList reviewersInput = reviewers().split(',', QString::SkipEmptyParts);
for (const QString &reviewer : reviewersInput)
options << "r=" + reviewer;
if (!options.isEmpty())
target += '%' + options.join(',');
return target;
}
void GerritPushDialog::storeTopic()
{
const QString branch = m_ui->localBranchComboBox->currentText();
@@ -302,11 +323,6 @@ QString GerritPushDialog::selectedRemoteBranchName() const
return m_ui->targetBranchComboBox->currentText();
}
QString GerritPushDialog::selectedPushType() const
{
return QLatin1String(m_ui->draftCheckBox->isChecked() ? "drafts" : "for");
}
QString GerritPushDialog::selectedTopic() const
{
return m_ui->topicLineEdit->text().trimmed();

View File

@@ -53,10 +53,10 @@ public:
QString selectedCommit() const;
QString selectedRemoteName() const;
QString selectedRemoteBranchName() const;
QString selectedPushType() const;
QString selectedTopic() const;
QString reviewers() const;
QString initErrorMessage() const;
QString pushTarget() const;
void storeTopic();
private: