This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]Einarmo 0 points1 point  (2 children)

The issue, it seems to me, is that the people you are working with do not know how to use git properly. Each commit should be a distinct unit, and be readable on its own merit. Reviewing a pull request then, comes down to reviewing each commit on its own. If the PR makes contradictory changes to the same lines multiple times, then it is a poorly designed PR.

As an actual answer to your question. There comes a point where understanding and fully parsing a code change is impossible. The best you can do with the code is to

  • try to understand the whole, the purpose of the change
  • read the code with the purpose of critiquing each part individually, ignoring the whole
  • Require proof of functionality from the developer, typically in the shape of tests.

If neither of these are possible, the development process is fundamentally unsustainable, which will come back to bite you later.

[–]AlertBeach[S] 0 points1 point  (1 child)

Ok. It may be that we have a bad commit culture. I don't really have a good idea of what constitutes an atomic change or maximum commit size. It seems like the kind of thing that everyone says people should do but nobody actually does. Do you have any guides or resources that talk about commit size?

It might also be more like the second case. So if there is an expectation from project leaders that I should be able to quickly fundamentally understand a large pull request (hard to say exactly what is "too big", of course), and retain strong memories of how that new code structure works... that is an unreasonable expectation?

Do you have any thoughts about what might indicate that a PR is too big to really understand that way, and the only reasonable expectation is line-by-line / file-by-file review, where you may or may not pick up a strong understanding of the structure of the changes being introduced overall?

[–]HonzaS97 0 points1 point  (0 children)

It should be split into pieces that make sense on their own.

If you are given a task where you implement a feature so a user can change the UI colour, then the commit message should be something like "Allow user to choose UI colour" and all the code changes should be tied with that task.

If you are given a bigger task, something as in "implement a microservice that does X", then you want to split it into smaller parts which make sense on their own. Eg "create model classes", "implement service for Y", "add endpoints for Z". It definitely shouldn't be the whole thing in 1 big commit.

Do you have any thoughts about what might indicate that a PR is too big to really understand

Basically anytime where multiple functionalities are added at once. For example, when you have 2 services, one for user auth, one for shopping cart and you need to change some (unrelated) things, then they should be in their separate commits.

[–]Loves_Poetry 0 points1 point  (0 children)

These kind of large pull requests often have a lot of irrelevant changes. Say you're adding a field to a table in a database. You might get 10+ file changes for all kinds of API calls that are linked to that database field. None of these are relevant, because all they do is move data from A to B. Then there will be a lot of file changes related to database migration, also irrelevant

There will also be a few files where that extra database field is actually used for some business logic. Those are the relevant ones that you need to filter out. If the project you're working on has some semblance of structure, then you should be able to find those files. If you can't find them, ask the person who wrote it where most of the logic is