Commit 7d573006 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Git: fetch from remote

Task-number: QTCREATORBUG-4942
Change-Id: Ifd8586e110379a621c43233fe9b912bd82f7f28a
Reviewed-on: http://codereview.qt.nokia.com/218

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 7f33ef02
......@@ -2087,9 +2087,11 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
}
}
bool GitClient::synchronousFetch(const QString &workingDirectory)
bool GitClient::synchronousFetch(const QString &workingDirectory, const QString &remote)
{
QStringList arguments(QLatin1String("fetch"));
if (!remote.isEmpty())
arguments << remote;
// Disable UNIX terminals to suppress SSH prompting.
const unsigned flags = VCSBase::VCSBasePlugin::SshPasswordPrompt|VCSBase::VCSBasePlugin::ShowStdOutInLogWindow
|VCSBase::VCSBasePlugin::ShowSuccessMessage;
......
......@@ -167,7 +167,7 @@ public:
bool cloneRepository(const QString &directory, const QByteArray &url);
QString vcsGetRepositoryURL(const QString &directory);
bool synchronousFetch(const QString &workingDirectory);
bool synchronousFetch(const QString &workingDirectory, const QString &remote);
bool synchronousPull(const QString &workingDirectory);
bool synchronousPush(const QString &workingDirectory);
......
......@@ -802,7 +802,7 @@ bool GitPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submitEdi
void GitPlugin::fetch()
{
m_gitClient->synchronousFetch(currentState().topLevel());
m_gitClient->synchronousFetch(currentState().topLevel(), QString());
}
void GitPlugin::pull()
......
......@@ -101,6 +101,7 @@ RemoteDialog::RemoteDialog(QWidget *parent) :
m_ui->remoteView->verticalHeader()->setDefaultSectionSize(qMax(static_cast<int>(fm.height() * 1.2), fm.height() + 4));
connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addRemote()));
connect(m_ui->fetchButton, SIGNAL(clicked()), this, SLOT(fetchFromRemote()));
connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeRemote()));
}
......@@ -152,6 +153,17 @@ void RemoteDialog::removeRemote()
}
}
void RemoteDialog::fetchFromRemote()
{
const QModelIndexList indexList = m_ui->remoteView->selectionModel()->selectedIndexes();
if (indexList.count() == 0)
return;
int row = indexList.at(0).row();
const QString remoteName = m_remoteModel->remoteName(row);
m_remoteModel->client()->synchronousFetch(m_remoteModel->workingDirectory(), remoteName);
}
void RemoteDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
......
......@@ -82,6 +82,7 @@ public slots:
void addRemote();
void removeRemote();
void fetchFromRemote();
private slots:
......
......@@ -70,6 +70,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="fetchButton">
<property name="text">
<string>Fetch</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeButton">
<property name="text">
......
......@@ -227,6 +227,11 @@ int RemoteModel::findRemoteByName(const QString &name) const
return -1;
}
GitClient *RemoteModel::client() const
{
return m_client;
}
} // namespace Internal
} // namespace Git
......@@ -69,6 +69,7 @@ public:
QString workingDirectory() const;
int findRemoteByName(const QString &name) const;
GitClient *client() const;
protected:
struct Remote {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment