This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[tools] Add update-release-info
#5643
Merged
fluttergithubbot
merged 7 commits into
flutter:main
from
stuartmorgan-g:tool-update-release-info
May 18, 2022
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cde14d8
[tools] Add `update-release-info`
stuartmorgan-g 1e6e3e3
Apply suggestions from code review
stuartmorgan-g 0d42f3f
Add md file handling
stuartmorgan-g c820112
Skip unchanged packages for 'minimal'
stuartmorgan-g 8bbf789
Merge branch 'main' into tool-update-release-info
stuartmorgan-g 62debc4
Merge branch 'flutter:main' into tool-update-release-info
stuartmorgan f7d69f3
Test updates from merge
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:meta/meta.dart'; | ||
| import 'package:path/path.dart' as p; | ||
|
|
||
| import 'repository_package.dart'; | ||
|
|
||
| /// The state of a package on disk relative to git state. | ||
| @immutable | ||
| class PackageChangeState { | ||
| /// Creates a new immutable state instance. | ||
| const PackageChangeState({ | ||
| required this.hasChanges, | ||
| required this.hasChangelogChange, | ||
| required this.needsVersionChange, | ||
| }); | ||
|
|
||
| /// True if there are any changes to files in the package. | ||
| final bool hasChanges; | ||
|
|
||
| /// True if the package's CHANGELOG.md has been changed. | ||
| final bool hasChangelogChange; | ||
|
|
||
| /// True if any changes in the package require a version change according | ||
| /// to repository policy. | ||
| final bool needsVersionChange; | ||
| } | ||
|
|
||
| /// Checks [package] against [changedPaths] to determine what changes it has | ||
| /// and how those changes relate to repository policy about CHANGELOG and | ||
| /// version updates. | ||
| /// | ||
| /// [changedPaths] should be a list of POSIX-style paths from a common root, | ||
| /// and [relativePackagePath] should be the path to [package] from that same | ||
| /// root. Commonly these will come from `gitVersionFinder.getChangedFiles()` | ||
| /// and `getRelativePoixPath(package.directory, gitDir.path)` respectively; | ||
| /// they are arguments mainly to allow for caching the changed paths for an | ||
| /// entire command run. | ||
| PackageChangeState checkPackageChangeState( | ||
| RepositoryPackage package, { | ||
| required List<String> changedPaths, | ||
| required String relativePackagePath, | ||
| }) { | ||
| final String packagePrefix = relativePackagePath.endsWith('/') | ||
| ? relativePackagePath | ||
| : '$relativePackagePath/'; | ||
|
|
||
| bool hasChanges = false; | ||
| bool hasChangelogChange = false; | ||
| bool needsVersionChange = false; | ||
| for (final String path in changedPaths) { | ||
| // Only consider files within the package. | ||
| if (!path.startsWith(packagePrefix)) { | ||
| continue; | ||
| } | ||
| final String packageRelativePath = path.substring(packagePrefix.length); | ||
| hasChanges = true; | ||
|
|
||
| final List<String> components = p.posix.split(packageRelativePath); | ||
| if (components.isEmpty) { | ||
| continue; | ||
| } | ||
| final bool isChangelog = components.first == 'CHANGELOG.md'; | ||
| if (isChangelog) { | ||
| hasChangelogChange = true; | ||
| } | ||
|
|
||
| if (!needsVersionChange && | ||
| !isChangelog && | ||
| // One of a few special files example will be shown on pub.dev, but for | ||
| // anything else in the example publishing has no purpose. | ||
| !(components.first == 'example' && | ||
| !<String>{'main.dart', 'readme.md', 'example.md'} | ||
| .contains(components.last.toLowerCase())) && | ||
| // Changes to tests don't need to be published. | ||
| !components.contains('test') && | ||
| !components.contains('androidTest') && | ||
| !components.contains('RunnerTests') && | ||
| !components.contains('RunnerUITests') && | ||
| // The top-level "tool" directory is for non-client-facing utility code, | ||
| // so doesn't need to be published. | ||
| components.first != 'tool' && | ||
| // Ignoring lints doesn't affect clients. | ||
| !components.contains('lint-baseline.xml')) { | ||
| needsVersionChange = true; | ||
| } | ||
| } | ||
|
|
||
| return PackageChangeState( | ||
| hasChanges: hasChanges, | ||
| hasChangelogChange: hasChangelogChange, | ||
| needsVersionChange: needsVersionChange); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can
--run-on-changed-packagesbe the default behavior for this tool, so people don't have to "remember" to pass it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would require some re-plumbing to allow a command to change the default package selection behavior, and it would make it inconsistent with all the other commands. But then, it's a different kind of command than most of the others.
I'll play around with that tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I came up with a different solution when I woke up this morning :) Instead of making this command have non-standard package targeting, I just made
minimalskip any package that has no changes at all. That makes it even easier to use, since you don't have to worry about the base treeish thatrun-on-changed-packagesis using.You'll still need to explicitly target for the other modes, but I don't expect the other modes to actually be useful in a bulk-update setting.