向 WebRTC 项目贡献代码

许可协议

WebRTC 欢迎针对功能和缺陷修复的补丁和拉取!

对于 Google 外部的贡献者,需要按照 Google 个人贡献者许可协议 中给出的指示完成操作。在所有情况下,贡献者在贡献的代码可以被接受之前,必须签署一份贡献者许可协议。请酌情为 个人公司 填写协议。

贡献示例

如果你想要添加一个新示例,或对一个已有的示例做出修改,我们建议你先创建一个 新问题,我们可以在那里讨论一些细节。

当要创建一个新的示例,或更新一个已有的,请确保你也创建,或更新任何已有的,测试。那个仓库中的所有测试都实现为 Nightwatch.JS UI 测试,因而请遵循你自己的相同设计。

指南

贡献你的第一个补丁

你必须做一些准备,以上传你的第一个 CL:

  • 检出并构建代码

  • 填写贡献者协议(见上)

  • 如果你以前从未提交过代码,你必须把你(或你的组织的情况下,对贡献者协议签了字的组织)的姓名和联系信息添加进 AUTHORS 文件

  • 转到 https://webrtc.googlesource.com/new-password 并用你的电子邮件账号登录。这个账号应该与 git config user.email 返回的相同。
    在这个页面,可以看到一段脚本代码,需要我们执行这段代码完成一些配置。如对于 Mac 和 Linux,笔者的账号登陆之后,这段代码如下:

eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
 touch ~/.gitcookies
 chmod 0600 ~/.gitcookies

 git config --global http.cookiefile ~/.gitcookies

 tr , \\t <<\__END__ >>~/.gitcookies
. . . . . .
__END__
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
  • 然后,运行:git cl creds-check。如果遇到了任何错误,可以在 discuss-webrtc 寻求帮助。这里成功执行的输出大体如下:
webrtc/src$ git cl creds-check
git is already configured to use your .gitcookies from /home/hanpfei/.gitcookies
Your .netrc and .gitcookies have credentials for these hosts:
                          Host	                 User	 Which file
==============================	=====================	===========
webrtc-review.googlesource.com	git-hanpfei.gmail.com	.gitcookies
       webrtc.googlesource.com	git-hanpfei.gmail.com	.gitcookies

No problems detected in your .gitcookies file.

你不需要每次都重复上面的步骤。完成了上面这些之后,你就为上传代码做好了准备。

上传你的第一个补丁

现在你已经创建好了你的账号,你可以执行实际的上传了:

  • 这样做:
    • 假设你在 main 分支上:
      • git checkout -b my-work-branch
    • 进行修改,在本地构建,在本地运行测试
      • git commit -am "Changed x, and it is working"
      • git cl upload
        这将打开一个文本编辑器,显示所有本地提交消息,这允许你在它成为 CL 描述之前对其进行修改。
        正确填写 bug 条目。请指定问题跟踪前缀和问题号,由冒号分割,如 webrtc:123chromium:12345。如果你没有问题跟踪前缀和问题号则只需添加 None。最好是在 https://bugs.chromium.org/p/webrtc/issues/list 创建一个。
        保存并关闭文件,以继续进行上传到 WebRTC 代码审查服务器 的操作。
        如果一切正常,则这个命令将打印一个链接,如 https://webrtc-review.googlesource.com/c/src/+/53121
        笔者在执行 git cl upload 时遇到了如下问题:
webrtc/src$ git cl upload
Running Python 2 presubmit upload checks ...
Python 2 presubmit checks passed.

Running Python 3 presubmit upload checks ...
Evaluation of CheckChangeOnUpload failed: Missing parentheses in call to 'print'. Did you mean print(' WARNING: import specified with no directory: ' + import_path)? (proto_checker.py, line 70)
Traceback (most recent call last):
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 2017, in <module>
    sys.exit(main())
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 1994, in main
    return DoPresubmitChecks(
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 1721, in DoPresubmitChecks
    results += executer.ExecPresubmitScript(presubmit_script, filename)
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 1590, in ExecPresubmitScript
    self._run_check_function(function_name, context, sink,
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 1628, in _run_check_function
    six.reraise(e_type, e_value, e_tb)
  File "/home/hanpfei/.vpython-root/b960a8/lib/python3.8/site-packages/six.py", line 686, in reraise
    raise value
  File "/home/hanpfei/bin/depot_tools/presubmit_support.py", line 1618, in _run_check_function
    result = eval(function_name + '(*__args)', context)
  File "<string>", line 1, in <module>
  File "PRESUBMIT.py", line 1207, in CheckChangeOnUpload
    results.extend(CommonChecks(input_api, output_api))
  File "PRESUBMIT.py", line 1012, in CommonChecks
    CheckUnwantedDependencies(input_api,
  File "PRESUBMIT.py", line 697, in CheckUnwantedDependencies
    import checkdeps
  File "/home/hanpfei/data/opensource/OpenRTCClient/webrtc/src/buildtools/checkdeps/checkdeps.py", line 20, in <module>
    import proto_checker
  File "/home/hanpfei/data/opensource/OpenRTCClient/webrtc/src/buildtools/checkdeps/proto_checker.py", line 70
    print ' WARNING: import specified with no directory: ' + import_path
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(' WARNING: import specified with no directory: ' + import_path)?

由错误输出可以看到,是某些检查脚本中,用了一些已经被 python 3 废弃的语法。这些语法错误如果要一个个去改,那可真要费死个劲了。笔者最终通过更新 webrtc/src/buildtools 的代码到最新版本来解决这个问题。

  • 点击这个 CL 链接

  • 如果你还没有登录,请单击右上角的登录按钮并使用你的电子邮件登录

  • 单击 Start Review 并添加 reviewer。你可以在代码仓库的 OWNERS 文件中找到 reviewer(取最接近您的更改的那个)。也可以通过修改的文件的 commit 历史来找到适当的 reviewer。如笔者需要修改 tools_webrtc/libs/generate_licenses.py,通过如下命令找到修改了这个文件的commit:

webrtc/src$ git log tools_webrtc/libs/generate_licenses.py
commit f2599a7f4374cb2d5b469c4d6d8e3250bad0a128
Author: Florent Castelli <orphis@webrtc.org>
Date:   Thu Mar 31 19:15:10 2022 +0200

    Remove usrsctp, dcSCTP is now the unique SCTP implementation
    
    Bug: chromium:1243702
    Change-Id: Id11299d26f0f8713a57781b57277837aace531f2
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251821
    Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
    Reviewed-by: Victor Boivie <boivie@webrtc.org>
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Florent Castelli <orphis@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#36423}
. . . . . .
commit 0e8f053867baae720cbbe1ddf4d63224e6e49687
Author: Henrik Kjellander <kjellander@webrtc.org>
Date:   Fri Sep 15 08:57:50 2017 +0200

    iOS: Fix license path in API framework script
    
    BUG=chromium:611808
    NOTRY=True
    NOTREECHECKS=True
    
    Change-Id: I4292a3f9e35da7666039402cf10bac1e0fd2a6b4
    Reviewed-on: https://webrtc-review.googlesource.com/1565
    Commit-Queue: Henrik Kjellander <kjellander@webrtc.org>
    Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
    Cr-Commit-Position: refs/heads/master@{#19847}

commit 67e414ce709446a3d6538bd9a4d027b698afa031
Author: sakal <sakal@webrtc.org>
Date:   Tue Sep 5 00:16:15 2017 -0700

    License generation script for build_aar.py.
    
    The script is forked from: tools_webrtc/ios/generate_licenses.py
    
    BUG=webrtc:8182
    
    Review-Url: https://codereview.webrtc.org/3011613002
    Cr-Commit-Position: refs/heads/master@{#19679}

在这些 commit 信息中,可以看到许多 Reviewed-by,这些即为我们要找到 reviewer。

  • 解决任何 reviewer 给出的反馈之后:

    • 进行修改,在本地构建,在本地运行测试
      • git commit -am "Fixed X and Y"
      • git cl upload
  • 一旦 reviewer LGTMs (approves) 了补丁,则请求他们把它放进提交队列

注意:在 Windows 上,你将需要在一个 Git bash shell 中运行上面的命令,以使 gclient 找到 .gitcookies 文件。

参考文档

Contributing to the WebRTC project

Done.

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值