The fact that I merged these two classes is not that important. Actually, if there was more logic in each of them, they would probably stay separate. The important point is that PostReader became coupled to Git support, which effectively made it a GitPostReader.

Commit Hook

Adding a commit hook sounds easy. It should be enough to create an endpoint to call a git pull command.

Testing

Final step, I have to test the whole thing. To be honest, while developing I used the old test. I configured the application to use the hello world repository. Then, I ran it and checked if it fails with a single README post with TILT's and a header.

As before, I'd like to test most cases via integration tests. It makes sense to me that integration tests would use a real, online Git repostory. In this case, it should be enough to move old test posts into an online repo and point my tests to use it. I'll also add a "TILT post" to check that the application doesn't crash in case of missing metadata fields.

♪♪♪ sounds of coding ♪♪♪

As said above, I moved test posts to a special repository. You can see it here.

I modified home test and added special tilt post test. For the "TILT post," I created a special assertTiltPost method.

That's it!

Oh boy/girl, that was fun! It was also easy, despite the fact that I used a new library and I didn't know how to test the feature at start. Step by step, small problem by small problem, I got the most important feature running in a few hours. If you experienced problems with mental overload during analysis before, you now know what to do — solve small problems!

Before I merge the changes, the application will be available here. Afterwards, it will be available under standard link. If you'd like to read final version of the code, contribute or w/e, project's repository is here.

Strategies and techniques for building scalable and resilient microservices to refactor a monolithic application step-by-step, a free O'Reilly book. Brought to you in partnership with Lightbend.