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

问题描述

我想开发一个与我在MSFT工作时使用的类似的轻量级代码审查流程。

进程:


  1. 开发人员进行更改。

  2. 开发人员包更改为某个存档文件
  3. >
  4. 开发人员将文件发送给开发团队

  5. 开发团队的随机成员,在差异工具中自动打开变更文件,记录笔记

  6. 如果代码是好的,随机成员会这么说,否则回复请求的笔记

只需要清楚:我知道如何更改代码(:D),并发送电子邮件。我想知道是否有直接的方法来创建更改的存档,并使用 git 轻松地在diff工具中查看它们。我想我可以创建一个 git patch 并发送邮件,但这只是故事的一半。我可以轻松查看修补程序 对当前代码库的作用吗?

我希望尽可能轻,否则它是不太可能完成代码审查,我坚信简单的代码审查过程会提高代码质量。

解决方案

使用。工作流程略有变化:
$ b


  1. 开发人员进行更改

  2. 开发人员提交代码

  3. 开发人员推送至Github

  4. 开发人员向团队负责人/审阅人发送拉取请求

  5. 审阅人员接受变更&将代码合并到主存储库中

Github并不是免费的,但考虑到它对你有什么作用,它很便宜。在接受或拒绝变更之前,您可以轻松地对增量(单个更改)或每行进行评论。您还可以将代码提取到本地存储库中,并查看,编译,运行,运行单元测试或任何您的心脏需求。

就评论者进行合并而言,我不认为有这样一种简单的方法。但是,您可以锁定祝福存储库,以便只有选定的人员才能推送(审阅者)。这样,代码审查就被迫了。在电子邮件系统中,即使您有补丁文件,审阅者仍然需要经历应用补丁和合并的过程。发送pull请求是补丁的一个步骤,因为git可以使用合并分支的历史记录来进行更好的猜测;这就是为什么在git中合并更容易。



这是一种非常普遍的情况。人们通常希望强制代码评论,而github使其无可否认容易。事实上,很多人开始仅仅为了强制代码评论而使用github。

I'd like to develop a lightweight code-review process that is similar to one that I used when I worked at MSFT.

This is a general outline of the process:

  1. Developer makes changes.
  2. Developer packs changes into some archive file
  3. Developer sends file to development team
  4. Random member of development team, opens change-file automagically in diffing utility, makes notes
  5. If code is good, random member says so, otherwise replies with requested notes

Just to be clear: I know how to change code (:D) , and send email. I'd like to find out if there is a straight-forward way to create a archive of changes, and easily view them in a diff tool using git. I think I can create a git patch and email that around, but that's only 1/2 of the story. Can I easily view what the patch would do to the current code base?

I want to make this as light as possible, because otherwise it's unlikely that code-reviews will get done, and I'm a firm believer that a simple code-review process will increase code quality.

解决方案

Use Github. The workflow changes slightly:

  1. Developer makes changes
  2. Developer commits code
  3. Developer pushes to Github
  4. Developer sends pull request to team lead/reviewer
  5. Reviewer accepts changes & merges code into the main repository

Github isn't free, but considering what it does for you, it's dirt cheap. You can easily make comments on a delta (single change) or per line before accepting or rejecting a change. You can also fetch the code into your local repository and view, compile, run, run unit tests, or whatever your heart desires.

As far as reviewers doing merges, I don't think there's an easy way to do this. However, you can lock down the "blessed" repository so that only select people can push to it (reviewers). That way, code reviews are forced. In the email system, even if you had patch files the reviewer would still have to go through the process of applying the patch and merging. Sending pull requests is a step up from patches because git can use the history of the merging branch to make a better educated guess; which is why merging in git tends to be easier.

This is a very common situation. People often want forced code reviews, and github makes it undeniably easy. In fact, many people start using github simply for forced code reviews.

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

09-19 06:50