I would like to see in Project Viewer the currently checked out git branch.
I'm not sure whether a change in git-plugin is sufficient or a change in Project viewer is required.
My idea would be to display the branch (instead of or) additionally to the project name in the project viewer tree. So if the project is called "foo" and the branch is "bar" the root of the tree should show "foo (bar)".
I couldn't yet find in the source how the name is displayed let alone how I could change this.
Anybody here who could do this change or guide me?
I've created a macro that helps (me) remedy the situation a bit:
When I call this macro, the current project's name is changed so that the current branch in square brackets is appended.
Do we have experts here which can enhance ProjectViewer and/or GitPlugin to do this automatically upon each (re-)import or opening of a project?
You could add essentially the same code to GitPlugin.java, like this:
However, I'm not sure the plugin should just automatically change the name of the project without the users saying so. Probably the GitPlugin should provide an option pane for ProjectViewer for the user to be able to choose this action.
If I'm not mistaken you already added it, right?
Unfortunately I get issues having the rename active. You cannot reimport a project and the troubleshoot utility shows exceptions.
Update: There must be a fundamental difference between what you did and what my Macro does.
I think it could be due to that my macro renames the project and you test whether or not to rename it by checking
But if you renamed it, the name changed. Could it be there is a mismatch between the name and the INTERNAL_NAME? Or that there is none and so the setting is still stored under the old name and so you cannot find it?
Maybe it's better to have a global GIT setting to rename every GIT project to include the branch?
I've tested by deactivating the storing of the property and the exception is gone.
So we either need to have the autorename be a global GIT option (I'd vote for that).
Or find a way to store it per project without having to deal with the problem that the property contains the project's name.
I also tried it by changing the "getProjectName" method in GitPVOptopnPane to
But other functionality then fails e.g. commiting. But it might fail anyway because the project name contains spaces and brackets.
I just pushed a change, would you give it a try? The change makes sure the rename happens on the EDT, which appears to fix the problem. I say "appears" because I rebuilt ProjectViewer to help with debugging this, so my version of ProjectViewer may not be the same as the one from the plugin manager. I don't think that should make a difference, but let me know if this change doesn't work for you.
Seems to work except for the creation of a project.
I created a project and choose my GitPlugin repo. I selected the new option but the branch name was not added.
I went to the fresh roject's properties and the option (Automatically add branch name to project name) was unchecked.
Upon setting the checkbox everything seems to work. I even added the german translation for the option and submitted a merge request for it.
How will the branch be updated? Re-import of files didn't do that.
I'll check, it updates when ProjectViewer sends a message on the EditBus, but it might not be checking for all the right messages, like on reimport.
FYI: Plugins > Git Plugin > Checkout Branch does not send a message on the EditBus, so the branch isn't updated in the view.
Additional Info: After checking out another branch, the setting about automatically adding the branch name is lost.
Update: Seems it's a per-branch setting ;)
I had the setting switch on on "master"
I switched to "staging" -> Setting lost
I swiched it on on "staging" and checked out "master"
Setting was there.
Last edit: Skeeve 2017-11-29