How to find the current git branch in a plugin Follow
Answered
The code is this:
List<GitRepository> repositories = GitUtil.getRepositoryManager(e.getProject()).getRepositories();
if (repositories.size() > 0){
System.out.println(repositories.get(0).getCurrentBranch());
}
Assuming you are using intellij community edition to build your plugin, you will need to add the following:
/snap/intellij-idea-community/185/plugins/git4idea/lib/git4idea.jar
( you can check the path for other jars in this window )
To:
File > Project Structure > SDKs > Intellij IDEA Community Edition IC-XXX.XXXX.XX > Classpath
Also, you will need to add the following to plugin.xml:
<depends>Git4Idea</depends>
https://github.com/uwolfer/gerrit-intellij-plugin/commit/ef256e28aea0412cb7bc8f42965e09549ec60bcd
Ref: https://github.com/zielu/GitToolBox/blob/master/src/main/resources/META-INF/plugin.xml
Please sign in to leave a comment.
Sorry, is this a question or ..?
Hello, This is not a question. Its a PSA. It took me a while to figure this out so I posted it hoping it will help someone in the future.
Ok. Please note that described way of setup uses Devkit-setup, which is not recommended for new plugins. See https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html.