如何使用GitHub进行代码审查? [英] How can one conduct a code review with GitHub?

查看:2382
本文介绍了如何使用GitHub进行代码审查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GitHub有一个很好的机制来讨论提交和拉取请求。但是,如果我已经创建了一个仓库,并且我想要人对我的仓库中的所有代码发表评论,那么什么是允许他们这样做的好方法?




  • 提交存在,但一次只显示代码窗口,因此我必须创建提交,覆盖所有文件的每一行

  • 如果是这样,我最好的选择是通过在每行末尾添加一个空格来触摸每个文件? (yuck)。我可以在一个分支中创建这个提交,然后发出一个拉请求到我自己的repo从该分支,以不污染主。

    • for x in< files of interest> ;; do seds / \ $ / / g$ x> $ x.new; mv $ x.new $ x;完成




http://stackoverflow.com/questions/12696158/comment-on-a-line-in-github-without-a-commit\">与无提交意见的相关问题。



更新:



从@VonC的灵感中,我使用了以下过程我相信是最简单和最好的,因为它不干扰主分支或要求我的审稿人花费任何额外的努力。



1。在我的repo的本地克隆中,我创建了一个名为code_review的分支。

  git checkout -b code_review 

2。在该分支中,我删除了所有需要审核的文件,并承诺进行更改并推送。

  git rm -rf * 
git commit -am文件代码审查
git push origin code_review -u

3。在Github上,从master分支,我发出了一个pull_req的代码_review分支。这是此项目主屏幕中的一个选项。



4。最后,我向审核人员发送了一个指向此请求的链接,以便他们可以逐行评论我的代码。

解决方案

更新2016年:在






如果您更改Github repo的默认分支通过空分支,管理fork的同事应该能够向您的Github仓库发出一个pull请求,这将显示完整的代码。


GitHub has a great mechanism for discussion around commits and pull requests. However, if I have created a repo, and I'd like someone to comment on all of the code in my repo, what's a good way to allow them to do so?

  • Commits exist, but only show windows of code at a time, so do I have to create commits which cover every line of all files of interest?
  • If so, is my best option to touch every file by adding a space at the end of each line? (yuck). I can create this commit in a branch and then issue a pull request to my own repo from that branch, to not pollute master.
    • for x in <files of interest>; do sed "s/\$/ /g" $x > $x.new; mv $x.new $x; done

Here's a related question on commenting without commits.

Update:

With inspiration from @VonC, I used the following process which I believe is the simplest and best, since it doesn't disturb the master branch or require my reviewers to expend any additional effort.

1. In my local clone of my repo, I created a branch called code_review.

git checkout -b code_review

2. In that branch, I removed any files I wanted reviewed, committed that change, and pushed.

git rm -rf *
git commit -am "files to be code reviewed"
git push origin code_review -u

3. At Github, from the master branch, I issued a pull request for the code_review branch. This was an option from the main screen for this project.

4. Finally, I sent my reviewers a link to this pull request so they could comment on my code line by line. Make sure to tell them to click on the "files changed" tab for inline commenting.

解决方案

Update 2016: At GitHub Universe 2016, GitHub introduced enhanced reviews

our first step is now available on all pull requests—Reviews. In addition to commenting on specific lines of code, Reviews let you formally "approve" or "request changes" to pull requests. You can also leave a review summary and delete, edit, or bundle comments before you submit them.


If you change the default branch of your Github repo by an empty branch, a colleague managing a fork should be able to do a pull request to your Github repo, which would show the full code.

这篇关于如何使用GitHub进行代码审查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆