How to set up a code review using Gitlab?

家住魔仙堡 提交于 2019-12-03 02:09:57

问题


How does one set up a code review using Gitlab? I see it listed as a feature on the Gitlab website, but I can't seem to find instructions on how to set one up (For that matter, any link to a Gitlab user manual would be most appreciated).

Some of my searching has indicated that 'Merge Requests' are the way to go... but I'm finding them limiting. An issued merge request shows all of the commits between one branch and the other. I seem to only be able to view diffs generated for each individual commit. For example, let's say I have a file I want to review. It is a new file but I've submitted changes to it over 10 commits on a dev branch. If I issue a merge request for that dev branch from integration I see 10 commits each of which show the incremental changes made to the file... I want to review the entire thing. It is new!

Am I barking up the wrong tree here? Is there an actual code-review tool I can use in GitLab, or are merge requests the way to go, and if they are am I using them incorrectly? what's the best way to set up a proper code review here?


回答1:


Note: since GitLab 6.4, side-by-side diff view is available: see "pull request 5308".

(July 2013)There is no possibility yet to comment on each line though, only at the file level.
Daniel Sokolowski mentions in the comments that Per line comments are now supported (09/2014):

Your team members can comment on the merge request in general or on specific lines with line comments.

That still can help for code review activity.




回答2:


I've been doing code reviews in Gitlab for over two months with almost no friction. I've setup rss2email to send email notifications everytime a developer pushes new commits. Then I use Gitlab's comment feature for commits to make some comments about the pushed code.

Unfortunately, Gitlab does not allow comments on files itself, only in commits (just like Github, I guess). Whenever I find myself in a situation that I need to comment something that I've missed in a previous commit, I use the blame tool to find the commit that introduced/changed the code section to be commented.

It is far from perfect, but it is working good so far.




回答3:


You can see submitted code in Merge Request for other repository or in current repository.
example http://demo.gitlab.com/diaspora/diaspora/commits/master

Then you can add comments to committed file changes (button Reply) or to the whole commit

example http://demo.gitlab.com/diaspora/diaspora/commit/42f47626890218a180870bc3f44ec57625b0779c

The resulting communication is code review. However, I personally recommend to do code review on one PC with face-to-face communication whenever possible, and use tools for recording results or when more formality is needed.

For a file revue that has a lot of commits, e.g. http://demo.gitlab.com/diaspora/diaspora/blame/master/README.md look at it using blame to understand who did what. However in this view there is no option to communicate and add comments. I would recommend just add changes as comments in this case.




回答4:


Yes. Merge requests are how peer reviews are accomplished.

There should be a 'diff' tab that will show the changes of all the commits (mentioned here: http://youtu.be/DyAX8ws5OIc?t=3m2s).

The video also explains nicely how it can be used to peer review.




回答5:


The normal use-case of code reviews is to review code on a branch before merging into master or similar. I have a situation where I've developed a project and want all the code to be reviewed by everyone on the team.

What I did was:

Checkout the first commit, make a change to it, commit and push

git co -b FIRST_COMMIT eb67f06c2b3222c0219214b176c41922bc454881
vi README.md
git add README.md
git ci -m "First commit modified so can get full diff against it"
git push --set-upstream origin FIRST-COMMIT

Checkout the last commit, make a change to it, commit and push

git co -b master
vi README.md
git add README.md
git ci -m "Last commit modified so can get full diff against it"
git push --set-upstream origin LAST-COMMIT

On GitLab / GitHub, create a pull request

  • It is one merging from LAST_COMMIT to FIRST_COMMIT

Works for me!



来源:https://stackoverflow.com/questions/17559719/how-to-set-up-a-code-review-using-gitlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!