Gerrit: Support pushing initial commit for review

Enable manual selection of target branch on this case.

Task-number: QTCREATORBUG-16780
Change-Id: I925ceef52ec56ebf77abcee58065c7b8afcc0854
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2016-08-25 22:16:02 +03:00
committed by Orgad Shaneh
parent 5b49ed506b
commit 8d14f76c10
2 changed files with 22 additions and 4 deletions

View File

@@ -150,6 +150,9 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
connect(m_ui->targetBranchComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &GerritPushDialog::setChangeRange);
connect(m_ui->targetBranchComboBox, &QComboBox::currentTextChanged,
this, &GerritPushDialog::validate);
updateCommits(m_ui->localBranchComboBox->currentIndex());
setRemoteBranches();
@@ -223,8 +226,17 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
const QString remoteName = selectedRemoteName();
if (!m_remoteBranches.contains(remoteName)) {
foreach (const QString &branch, GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir))
const QStringList remoteBranches =
GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir);
foreach (const QString &branch, remoteBranches)
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
if (remoteBranches.isEmpty()) {
m_ui->targetBranchComboBox->setEditable(true);
m_ui->targetBranchComboBox->setToolTip(
tr("No remote branches found. This is probably the initial commit."));
if (QLineEdit *lineEdit = m_ui->targetBranchComboBox->lineEdit())
lineEdit->setPlaceholderText(tr("Branch name"));
}
}
int i = 0;
@@ -250,8 +262,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
void GerritPushDialog::updateCommits(int index)
{
const QString branch = m_ui->localBranchComboBox->itemText(index);
const bool hasLocalCommits = m_ui->commitView->init(m_workingDir, branch,
LogChangeWidget::Silent);
m_hasLocalCommits = m_ui->commitView->init(m_workingDir, branch, LogChangeWidget::Silent);
const QString remoteBranch = determineRemoteBranch(branch);
if (!remoteBranch.isEmpty()) {
@@ -265,8 +276,13 @@ void GerritPushDialog::updateCommits(int index)
else
setRemoteBranches();
}
validate();
}
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(hasLocalCommits);
void GerritPushDialog::validate()
{
const bool valid = m_hasLocalCommits && !selectedRemoteBranchName().isEmpty();
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);
}
QString GerritPushDialog::selectedRemoteName() const