Hands-on with Atomic Commits — Part 5: Clean up!

J Silva
4 min readJun 9, 2022

--

In the last part, as you can see in the figure below, we still have uncommitted files in our repository.

What would you do? Clean up!

We first need to identify the remaining packages in the remaining file set. We can clearly see that we have an entity package, a main package and a package with root files.

So we need to put these three packages in the correct branches. The first one is related to the entities and should be placed in the first commit (database pkg) because this package is dependent on the entities and needs the entities so that it can run correctly. To do this we need to change your current branch to ac-1-database as shown below.

After that we can commit the entities package.

Now we need to choose the next package to commit, and we realize that the main files are needed in the first commit too, because without them the system can run. Let’s commit these files.

Now we will have the pull request previous opened like shown in the picture bellow.

But as you can see, we still have one file left. Let’s think for a moment, that package needs to be committed in this branch? What do you think?

If your response was no, I agree with you because the main.go file is not needed to test the database package. So, what branch really needs this file?

Yep, you’re right. The main.go file is only needed to the last commit because it needed to run the API tests . Let’s finish this. Go to the ac-5-http branch and commit this guy.

Now we will have the pull request previous opened like shown in the picture bellow.

The title of this title sound a little weird, I think is better to change it to one that suits better.

After all these changes we will have the pull requests below:

Yeah! Now we have our home clean up! 🎉

And that’s it, we finish with the divide and conquer strategy, and some points can be observed with this strategy:

  1. It’s more hard for developers because they need to create multiple branches and pull requests
  2. The order of commits and pull requests still matters
  3. Is very easy for reviewers do your job but they will need to review more PRs in the same way, after all the number of file are the same.

Now let’s move to the reviewers side and see how atomic commits help their work, click next to find out. 😎

Next: Hands-on with Atomic Commits — Part 6: Code Review

Previous: Hands-on with Atomic Commits — Part 4: Divide and Conquer Strategy

--

--

J Silva

+20 years of development experience. Golang Lover. Linux Soldier. Blockchain enthusiast.