dfuenzalida / gedit-git-branch-statusbar

Gedit plugin: Shows the Git branch of the current file on the status bar
https://github.com/dfuenzalida/gedit-git-branch-statusbar
10 stars 0 forks source link

Gedit 3 now supports only python3 plugins #3

Closed aciapetti closed 5 years ago

aciapetti commented 5 years ago

In the new Gedit 3 only python3 plugins are supported. Enabling git-branch-statusbar plugin now produces the error: WARNING **: Could not find loader 'python' for plugin "git-branch-statusbar"

Can you please update the plugin to make it work on the Gedit version included in Ubuntu 18.04 LTS?

Thanks Andrea

dfuenzalida commented 5 years ago

Hi Andrea, thanks for reporting this issue and I'm glad it is (or was) useful to you. However, as you can see, I haven't touched this repo in ages (since late 2011!). Would you be interested in cloning the repo and sending me a pull request?

I had a quick look and maybe all that needs to be changed is adding a line at the top of git-branch-statusbar-plugin.py as in this StackOverflow answer: https://stackoverflow.com/a/19305076

aciapetti commented 5 years ago

Hi Denis, thanks for the quick reply. I'll try to check it during the weekend. Hope of being able to do so.

dfuenzalida commented 5 years ago

OK, it seems I was able to figure the things I needed to update for it to work on Ubuntu 18.04:

I'll push my changes shortly, here's a screenshot from my laptop:

gedit-ubuntu-18

dfuenzalida commented 5 years ago

It seems that should do. Please pull from the repo, try installing it on your computer and let me know if it works. Sorry for just going ahead before you tried!

On the other hand, if you find this plugin to be useful, and want to make UX improvements (eg. the label could be prettier, maybe getting rid of that border, or maybe using some padding) you are more than welcome to contribute.

aciapetti commented 5 years ago

Thanks a lot, Denis. It's working nicely now! On my company repositories, it's not detecting the git branch, though. Do you have any idea why? See images attached.

git_branch

no_branch_here

aciapetti commented 5 years ago

Perhaps we can add some other simple info, like the status of the repository (are there changed or untracked files? use different colors for different situations...) and a simple icon for git branches. Obtaining the info is pretty simple: print('Repo is in dirty status {}'.format(repo.is_dirty())) print('Repo untracked files {}'.format(len(repo.untracked_files))) print('Repo changed files {}'.format(len(repo.index.diff(None)))) Icons: git-branch git-tree

Something like this: panel

WDYT?

dfuenzalida commented 5 years ago

On my company repositories, it's not detecting the git branch, though. Do you have any idea why?

I guess what's happening is that the plugin only looks in the directory of the current file being edited, but not recursively on the parent, so if you edit a file like <project-root>/dir1/myfile.txt it won't find the root of the Git repo. I'll take a look at that this weekend.

aciapetti commented 5 years ago

Yes. You're right. Try git_repo = git.Repo(dir_path, search_parent_directories=True) instead of repo = git.Repo(dir_path).

dfuenzalida commented 5 years ago

Yes, using search_parent_directories=True did the trick:

gedit-subdirs

@aciapetti I've pushed this change to the repo in the latest commit b8f59c0d10f1f0aad3392c3f210925e78b6c9c7e ... please confirm if it works on your company repos.

For handing the UI enhancements, I'll create a separate issue and some links to the Python-gtk3 tutorial so we can how feasible would be to include a Git logo in the status bar, etc.

aciapetti commented 5 years ago

Thanks a lot @dfuenzalida, the plugin is now working perfectly on each case I've tested. I think you can close this issue. Thanks again for the prompt reply and for the wonderful collaboration. I'll contact you via mail directly on GMail to show you my small steps forward in the issue #4