Qt Creator 4 custom plugin get current branch for project under version control
Unsolved
Qt Creator and other tools
-
I have noticed when creating a qmake project, that if it is under version control the branch name shows up in the project node display text. I have searched for hours and I have been unsuccessful at locating where this happens within the source code. The reason I ask, is I have a custom project manager plugin that will contain multiple repositories and I would like to display the current branch in the folder node display text.
-
I figured out how to get the branch information. The code is below that I used to get the branch information given an absolute path.
Headers:
#include <coreplugin/vcsmanager.h> #include <coreplugin/iversioncontrol.h>
Code:
bool ROSProjectNode::hasVersionControl(const QString &absolutePath, QString &vcsTopic) const { if (Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory(absolutePath)) { if (absolutePath == Core::VcsManager::findTopLevelForDirectory(absolutePath)) { vcsTopic = vc->vcsTopic(absolutePath); return true; } } return false; }