未验证 提交 a2a3dc05 编写于 作者: C Chris Bracken 提交者: GitHub

Catch divide-by-zero errors early in license tool (#4382)

If Progress is instantiated with a max of 0, throw immediately to avoid
a divide-by-zero later in toString(). This typically happens if the tool
recurses over an empty top-level component, which can happen when a
component is moved around in the repo and the developer hasn't cleaned
up old empty directories from their git client.
上级 546cc39f
......@@ -2313,7 +2313,13 @@ class RepositoryRoot extends RepositoryDirectory {
class Progress {
Progress(this.max);
Progress(this.max) {
// This may happen when a git client contains left-over empty component
// directories after DEPS file changes.
if (max <= 0)
throw new ArgumentError('Progress.max must be > 0 but was: $max');
}
final int max;
int get withLicense => _withLicense;
int _withLicense = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册