mirror of
https://github.com/flutter/packages.git
synced 2025-06-08 21:09:17 +08:00
[tool] Bypass version/changelog checks for some PRs (#6124)
This commit is contained in:
@ -569,11 +569,15 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
|
||||
}
|
||||
|
||||
if (state.needsVersionChange) {
|
||||
if (_getChangeDescription().split('\n').any((String line) =>
|
||||
final String changeDescription = _getChangeDescription();
|
||||
if (changeDescription.split('\n').any((String line) =>
|
||||
line.startsWith(_missingVersionChangeJustificationMarker))) {
|
||||
logWarning('Ignoring lack of version change due to '
|
||||
'"$_missingVersionChangeJustificationMarker" in the '
|
||||
'change description.');
|
||||
} else if (_isAllowedDependabotChange(package, changeDescription)) {
|
||||
logWarning('Ignoring lack of version change for Dependabot change to '
|
||||
'a known internal dependency.');
|
||||
} else {
|
||||
printError(
|
||||
'No version change found, but the change to this package could '
|
||||
@ -587,11 +591,15 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
|
||||
}
|
||||
|
||||
if (!state.hasChangelogChange) {
|
||||
if (_getChangeDescription().split('\n').any((String line) =>
|
||||
final String changeDescription = _getChangeDescription();
|
||||
if (changeDescription.split('\n').any((String line) =>
|
||||
line.startsWith(_missingChangelogChangeJustificationMarker))) {
|
||||
logWarning('Ignoring lack of CHANGELOG update due to '
|
||||
'"$_missingChangelogChangeJustificationMarker" in the '
|
||||
'change description.');
|
||||
} else if (_isAllowedDependabotChange(package, changeDescription)) {
|
||||
logWarning('Ignoring lack of CHANGELOG update for Dependabot change to '
|
||||
'a known internal dependency.');
|
||||
} else {
|
||||
printError(
|
||||
'No CHANGELOG change found. If this PR needs an exemption from '
|
||||
@ -605,4 +613,46 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog.
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Returns true if [changeDescription] matches a Dependabot change for a
|
||||
/// dependency roll that should bypass the normal version and CHANGELOG change
|
||||
/// checks (for dependencies that are known not to have client impact).
|
||||
bool _isAllowedDependabotChange(
|
||||
RepositoryPackage package, String changeDescription) {
|
||||
// Espresso exports some dependencies that are normally just internal test
|
||||
// utils, so always require reviewers to check that.
|
||||
if (package.directory.basename == 'espresso') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A string that is in all Dependabot PRs, but extremely unlikely to be in
|
||||
// any other PR, to identify Dependabot PRs.
|
||||
const String dependabotMarker = 'Dependabot commands and options';
|
||||
// Expression to extract the name of the dependency being updated.
|
||||
final RegExp dependencyRegex =
|
||||
RegExp(r'Bumps? \[(.*?)\]\(.*?\) from [\d.]+ to [\d.]+');
|
||||
|
||||
// Allowed exact dependency names.
|
||||
const Set<String> allowedDependencies = <String>{
|
||||
'junit',
|
||||
'robolectric',
|
||||
};
|
||||
const Set<String> allowedDependencyPrefixes = <String>{
|
||||
'mockito-' // mockito-core, mockito-inline, etc.
|
||||
};
|
||||
|
||||
if (changeDescription.contains(dependabotMarker)) {
|
||||
final Match? match = dependencyRegex.firstMatch(changeDescription);
|
||||
if (match != null) {
|
||||
final String dependency = match.group(1)!;
|
||||
if (allowedDependencies.contains(dependency) ||
|
||||
allowedDependencyPrefixes
|
||||
.any((String prefix) => dependency.startsWith(prefix))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user