forked from qt-creator/qt-creator
Vcs: Add variables containing the Vcs name (Git, etc.) and topic
This allows to have the git branch names (or tags, etc.) in the build path or to pass that information to scripts. Task-number: QTCREATORBUG-10376 Change-Id: I151990bdc7b85abbb427b2afae220adb4e918f4f Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -49,6 +49,9 @@ const char VCS_ID_SUBVERSION[] = "J.Subversion";
|
|||||||
const char VCS_ID_PERFORCE[] = "P.Perforce";
|
const char VCS_ID_PERFORCE[] = "P.Perforce";
|
||||||
const char VCS_ID_CVS[] = "Z.CVS";
|
const char VCS_ID_CVS[] = "Z.CVS";
|
||||||
|
|
||||||
|
const char VAR_VCS_NAME[] = "CurrentProject:VcsName";
|
||||||
|
const char VAR_VCS_TOPIC[] = "CurrentProject:VcsTopic";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,20 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "vcsplugin.h"
|
#include "vcsplugin.h"
|
||||||
|
|
||||||
|
#include "vcsbaseconstants.h"
|
||||||
|
|
||||||
#include "commonsettingspage.h"
|
#include "commonsettingspage.h"
|
||||||
#include "nicknamedialog.h"
|
#include "nicknamedialog.h"
|
||||||
#include "vcsbaseoutputwindow.h"
|
#include "vcsbaseoutputwindow.h"
|
||||||
#include "corelistener.h"
|
#include "corelistener.h"
|
||||||
|
|
||||||
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/mimedatabase.h>
|
#include <coreplugin/mimedatabase.h>
|
||||||
|
#include <coreplugin/variablemanager.h>
|
||||||
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -74,6 +82,15 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
connect(m_settingsPage, SIGNAL(settingsChanged(VcsBase::Internal::CommonVcsSettings)),
|
connect(m_settingsPage, SIGNAL(settingsChanged(VcsBase::Internal::CommonVcsSettings)),
|
||||||
this, SLOT(slotSettingsChanged()));
|
this, SLOT(slotSettingsChanged()));
|
||||||
slotSettingsChanged();
|
slotSettingsChanged();
|
||||||
|
|
||||||
|
connect(Core::VariableManager::instance(), SIGNAL(variableUpdateRequested(QByteArray)),
|
||||||
|
this, SLOT(updateVariable(QByteArray)));
|
||||||
|
|
||||||
|
Core::VariableManager::registerVariable(Constants::VAR_VCS_NAME,
|
||||||
|
tr("Name of the version control system in use by the current project."));
|
||||||
|
Core::VariableManager::registerVariable(Constants::VAR_VCS_TOPIC,
|
||||||
|
tr("The current version control topic (branch or tag) identification of the current project."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +139,32 @@ void VcsPlugin::slotSettingsChanged()
|
|||||||
populateNickNameModel();
|
populateNickNameModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VcsPlugin::updateVariable(const QByteArray &variable)
|
||||||
|
{
|
||||||
|
static ProjectExplorer::Project *cachedProject = 0;
|
||||||
|
static Core::IVersionControl *cachedVc = 0;
|
||||||
|
static QString cachedTopLevel;
|
||||||
|
|
||||||
|
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject();
|
||||||
|
if (cachedProject != project) {
|
||||||
|
cachedVc = Core::VcsManager::findVersionControlForDirectory(project->projectDirectory(),
|
||||||
|
&cachedTopLevel);
|
||||||
|
cachedProject = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variable == Constants::VAR_VCS_NAME) {
|
||||||
|
if (cachedVc)
|
||||||
|
Core::VariableManager::insert(variable, cachedVc->displayName());
|
||||||
|
else
|
||||||
|
Core::VariableManager::remove(variable);
|
||||||
|
} else if (variable == Constants::VAR_VCS_TOPIC) {
|
||||||
|
if (cachedVc)
|
||||||
|
Core::VariableManager::insert(variable, cachedVc->vcsTopic(cachedTopLevel));
|
||||||
|
else
|
||||||
|
Core::VariableManager::remove(variable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotSettingsChanged();
|
void slotSettingsChanged();
|
||||||
|
void updateVariable(const QByteArray &variable);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void populateNickNameModel();
|
void populateNickNameModel();
|
||||||
|
|||||||
Reference in New Issue
Block a user