How do I review an entire codebase on github?
Asked Answered
B

1

6

I would like to review all of the code in a single branch of a git repo on GitHub. (I am a professor, and the code is part of a student's thesis.) Any single commit affects only a small portion of the code. How can I perform a review that allows me to make per-line comments on all of the code from any commit?

I believe this question is related to How can I make a github PR requesting review of entire files?, which was never answered.

Bender answered 29/1, 2021 at 20:31 Comment(0)
O
-1

Navigate to the repo, then select the branch (for example) with the dropdown:

Then after the switch you can choose to Compare or Pull request which will display again at the top of the repo file list - in both you can compare, but PR option can open a "ticket" for merging - the request to pull from a branch.

Or you can click on the commits link:

Then simply open the commit (if you check from Compare or Pull request and within the diff itself you can hover over specific lines. Once the cursor hovers a + sign appears. You can comment and the author will get a notification via email.

Note: while reviewing the whole codebase is possible through commits, make sure you know what state you're reviewing because the commit comment won't simply disappear as if in a Pull request. It'll stay there, so you'll need to somehow make a note that it's resolved (unless GitHub added a new feature I'm not aware of) and check again e.g. in master branch whether the part of the file has been resolved.

It's quite a cumbersome process though, so it'll be okay probably just for smaller sections of the codebase or for school projects as it doesn't scale well due to the comments remaining in place and required manual task of checking whether the review comments have been taken into consideration / implemented.

For scaling you can use perhaps a more intrusive, but more scalable technique such as creating a new empty repo (or a new branch, then while :;do git reset HEAD~ --hard;done up to initial commit) and adding relevant file(s) grouped by a feature they represent (and hopefully a test, because it'll definitely break the codebase for a while) and then start opening PRs for each, review, let GitHub remove the comments and merge when the code is of a sufficient quality. Still though, it's a workaround when trying to treat git as a simple folder structure, which it is not - rather a graph/tree.

Alternatively you can create a task list for your student/colleague/peer where s/he can mark the tasks as completed or open a completely new issue with relevant lines referenced by a permalink.

Odom answered 29/1, 2021 at 20:40 Comment(4)
Thank you. After selecting the branch (there is only one, main), I don't see the option Compare or Pull Request. There is the "Pull requests" link, but there aren't any PRs. imgur.com/a/yViD7Rw I know how to make comments on commits or PRs, which is how I usually do it, although, as you mention, there are downsides to stepping through the commit graph.Bender
You don't see Compare because there isn't an another branch to compare to, unfortunately. You don't necessarily need to comment under PRs, you can open any commit (via History/Blame) in the repo tree anywhere and comment on any line if you have sufficient access in the repo.Odom
Thanks. I do have access. What I'd like is to create a PR for the whole set of code. I guess I could have the student create a new branch, remove everything from that branch, then merge in everything from main. I was just hoping there was a better way.Bender
Hm, yes, but mostly works for a repo that has been initialized with an empty commit otherwise you won't see everything and the larger the init commit's diff is, the less you'll see. See the edited answer. You can create a new branch with git checkout -b mybranch then revert all commits up to the initial one (e.g. while true in combination with git reset), push and then open a pull request into that branch.Odom

© 2022 - 2024 — McMap. All rights reserved.