git repo manager
Here is the start of a git repo manager for pythonista. I was frustrated with some limitations of the shellista git, and in some cases a graphical display makes more sense. The repo dropdown menu shows all repos on the device, and when a repo is selected, you can select the branch to commit to, or checkout. Remotes are supported, though the remote branch name has to match the local branch for now for pushing, and pulling will pull all remote branches I think...
Staging, unstaging, etc are managed by the buttons in the lower section. Also, one can view a diff of a modified file against the current HEAD, or open in the editor.
There really is no proper merge support, though you can sort of merge/rebase by selecting a branch without checking out, then committing modified files to the branch...
There were some fun ui pieces in here that might be of interest to others: a dropdown list, which populates in a Thread to allow expensive os.walk type populating in a responsive and cancelable way. Also, there is a simple uidialog class, (probably OBE when 1.6 comes out) -- notable in that it uses callbacks rather than acting modally, yet simulates a modal behavior by overlaying a transparent layer over the Root view.
Dropdown class for repo selection
Dialog class, auto created based on a dict, and returns a dict of values entered by user to a user specified callback.
Very cool! Finally I can review my changes before committing them!
I noticed a couple of bugs:
- the first time I tried to run it (after running install_gitview), it failed with an ImportError for the drop down module. Had to restart Pythonista to get it working
- when trying to push something (to my github repo) it prompts for credentials and Pythonista freezes.
Strange re item 1. Dropdown shouldn't depend on any of the things getting installed. I'll take a look.
Whoops on item 2. I have to admit I didn't test that well - I'm reusing the shellista code that has an input alert. I think I wrapped it in ui.
in_background, but it probably needs a delay as well, since ui and I out alerts don't always play nicely.
EDIT: I updated github with a new custom get_pass implementation that will prompt for a password if one is not on the keychain. Press the resetPW to remove credentials from the keychain, such as if you change your github PW. right now, this doesn't support having multiple github accounts, or a difference account per repo.
Item 1 might be a Pythonista issue. Seems that it gets confused if you update code outside of the editor
Item 2 works now like a charm. Thanks!
after cloning a repo I can't start gitui anymore. Line 388 KeyError: 'HEAD'. Any idea (I forget to define a local path...) how can I fix this?
Des last edited by
I used shellista to clone gitview into a folder gitview at top level (no errors), then ran install_gitview (no errors), then ran gitui and get:
Line 18: no module named dropdown
Do I need to clone into a specific folder for it to work? I suspect this is operator error on my part.
@Des: I had exactly the same problem, see above. Just force-quit and restart Pythonista
@brumm. Ack, apparently, I didn't realize that except takes only parenthesized tuples... So KeyError wasn't actually being caught where it should have. So much for
special cases are not so special to break the rules!
I just updated the repo with a fix. hopefully I've fixed the issue with dropdown import error too.
Brumm, you may need to delete the .git folder that was created in gitview.
import shutil,os #maybe a bad .git was created here: shutil.rmtree(os.path.expanduser('~/Documents/gitview/.git')) #or, quite possibly here: shutil.rmtree(os.path.expanduser('~/Documents/.git'))
Or, if you are running shellista or stash, just check if the gitview folder has a .git, and if so, delete it.
@JonB: Thank you for the hint with the hidden folder. I downloaded your latest update and clone a repo, but I got "WARNING:root:Repo is of type <type 'NoneType'>"!?
And last but not least: Thank you for git repo manager, really great.
Did the repo clone ok? I think this happens sometimes when the repo is first created, but not yet populated.
I updated with a few bug fixes(new repos were not getting initialized correctly).
The condition that caused the warning is checked, and a proper hud alert is issued.
Also, clone will check for a few common errors and handle them (namely, an existing local folder, or a github address that does not end with .git).
Clone failures are now reported rather than silently failing.
Clone will check the clipboard for a url, and prepopulate the dialog with the url, and try to guess a repo name as well.
Repo is complete (all 42 files). Hopefully I have more time at the weekend to test your update.