向 WebRTC 项目贡献代码

2022-04-20  本文已影响0人  hanpfei

许可协议

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

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

贡献示例

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

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

指南

贡献你的第一个补丁

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

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
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.

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

上传你的第一个补丁

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

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 的代码到最新版本来解决这个问题。

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。

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

参考文档

Contributing to the WebRTC project

Done.

上一篇 下一篇

猜你喜欢

热点阅读