Skip to main content

Starting Work on Git-the-Branch

The Itch

Aiming to write a tool using this which will show all the git branches in the current directory and the last commit date on those branches (and only the local branches :))

What I did today

I had to carry my phone in to the service centre, so I did not quite have as much focussed time as yesterday, with all the coordinating and carrying, but I learned a few new things

Kushal hinted that I could use GitPython to do what I want.
So I spent a little while reading there.
And then decided to test it out.

And then immediately went yak shaving, because I wanted to solve the problem of how to quickly type iterate in Visual Studio Code.
I learnt lots of Python using Reuven Lerner’s courses and I used a lot of Jupyter Notebooks then.
And I love them.
The trick now, is to figure out how to use them in Visual Studio Code.
To my delight, the Python extension in VS Code has support for notebooks. And all works well for the most part.
The only thing that tripped me up was that when I tried importing a module in the notebook after activating my virtual environment, the Jupyter server hiccoughed and threw up some error about not finding the module (which I knew was definitely installed) and then something about it not being in the PYTHONPATH (which I had no clue of which places, it was looking in.)
A little snooping and I realised that the extension loads the server with a default kernel in someplace. And I need to tell it about my environment. Once I told it to use the kernel from my venv, all was fine.
VS Code went and installed a ton of things and found what was already there and everything was hunky dory.
A from git import Repo worked just fine.

I felt good about this piece of dawdling, because I know this is something I am going to do every day and better I spend some time figuring it out, right at the start.

I learnt that I could use the ! mark as a prefix in Jupyter to run shell commands! A !ls will show me the contents of my folder :)

I skimmed the GitPython documentation.
I kind of got what I want.
This will require lots more work, which I shall have to put in.
But even a cursory glance, showed me that GitPython was an exhaustive wrapper, that would let you do practically anything you would want to do with Git.

More tomorrow …


P.S. Subscribe to my mailing list!
P.P.S. Feed my insatiable reading habit.