One of my proposal for Pagure was to have private repositories. Private repositories are basically repositories which are visible to you and people you give permission to.
To be honest , I thought it would require a few tweaks and I will be good to go, but that wasn’t the case and the insights I got working on this feature was amazing. I fiddle with this project on primarily three stages. Each stage was a challenge in its own.
The three stages were:
- Database Query
The UI was suppose to have a checkbox saying “Private” and when a user ticks it the existing project becomes private or the new project is private from the time it is conceived.
Achieving this was a joy ride, with flask I just need to make changes in the form and setting page UI and Voilla!
I introduced a column Private in the project table and that was pretty much it. Nice and beautiful.
This was the most challenging part for me , since I have not worked with databases, and this was out of my comfort zone, I actually went back to my database basics to see if I am doing things right.
We in Pagure use Sqlalchemy as the ORM layer, ORM stands for object relation mapper. It basically use to map databases to object-class model of representing data. Sqlalchemy is a really powerful tool.
While figuring out ways to get all admins who can view private projects , I struggled a lot since I was working with a function which forms the core of Pagure so if things go wrong with this function the whole Project will take a hit.
So the challenge was to make minimum changes which are independent so that it doesn’t compromise the existing functionality and yet able to introduce a new one. I struggle to achieve it I failed a lot of time , was working hard to get it working , constantly moving to the board to figure out a solution on paper. Then switching back to my screen to code it out.
Finally after struggling a lot I got a very beautiful solution and done !
Just when I thought I am done , there comes a question of writing tests. Since I have altered a very major functionality that means I need to test every aspect of it.
Testing was a herculean task since I have not done a lot of testing, I actually got a lot to learn for starting the DB used for testing is a in-memory DB and not the one used by the app.
The session maintained has to be replicated in a way to use them in the test and how to use pygit to actually initialize a repo with git init and use it.
Towards the end of this PR my development evolve from writing code and testing it , to write the test and then introduce code or write code that pass the test. It has been really amazing working on this feature and hope it will be integrated soon.
I think may be a little more work is required on this feature maybe. It feels really amazing to do this work.
The link to the branch on Pagure.
The link to the current Pull-Request.
Did you find this article valuable?
Support Farhaan Bukhsh by becoming a sponsor. Any amount is appreciated!