|
| 1 | +// Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +/// Returns true for repository-level paths of files that do not affect *any* |
| 6 | +/// code-related commands (example builds, Dart analysis, native code analysis, |
| 7 | +/// native tests, Dart tests, etc.) for use in command-ignored-files lists for |
| 8 | +/// commands that are only affected by package code. |
| 9 | +bool isRepoLevelNonCodeImpactingFile(String path) { |
| 10 | + return <String>[ |
| 11 | + 'AUTHORS', |
| 12 | + 'CODEOWNERS', |
| 13 | + 'CONTRIBUTING.md', |
| 14 | + 'LICENSE', |
| 15 | + 'README.md', |
| 16 | + // This deliberate lists specific files rather than excluding the whole |
| 17 | + // .github directory since it's better to have false negatives than to |
| 18 | + // accidentally skip tests if something is later added to the directory |
| 19 | + // that could affect packages. |
| 20 | + '.github/PULL_REQUEST_TEMPLATE.md', |
| 21 | + '.github/dependabot.yml', |
| 22 | + '.github/labeler.yml', |
| 23 | + '.github/post_merge_labeler.yml', |
| 24 | + '.github/workflows/pull_request_label.yml', |
| 25 | + ].contains(path); |
| 26 | +} |
| 27 | + |
| 28 | +/// Returns true for native (non-Dart) code files, for use in command-ignored- |
| 29 | +/// files lists for commands that aren't affected by native code (e.g., Dart |
| 30 | +/// analysis and unit tests). |
| 31 | +bool isNativeCodeFile(String path) { |
| 32 | + return path.endsWith('.c') || |
| 33 | + path.endsWith('.cc') || |
| 34 | + path.endsWith('.cpp') || |
| 35 | + path.endsWith('.h') || |
| 36 | + path.endsWith('.m') || |
| 37 | + path.endsWith('.swift') || |
| 38 | + path.endsWith('.java') || |
| 39 | + path.endsWith('.kt'); |
| 40 | +} |
| 41 | + |
| 42 | +/// Returns true for package-level human-focused support files, for use in |
| 43 | +/// command-ignored-files lists for commands that aren't affected by files that |
| 44 | +/// aren't used in any builds. |
| 45 | +/// |
| 46 | +/// This must *not* include metadata files that do affect builds, such as |
| 47 | +/// pubspec.yaml. |
| 48 | +bool isPackageSupportFile(String path) { |
| 49 | + return path.endsWith('/AUTHORS') || |
| 50 | + path.endsWith('/CHANGELOG.md') || |
| 51 | + path.endsWith('/CONTRIBUTING.md') || |
| 52 | + path.endsWith('/README.md'); |
| 53 | +} |
0 commit comments