Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Fix and update version checks (#3792)
Browse files Browse the repository at this point in the history
Currently our version update checks aren't actually working; the script doesn't work correctly if no explicit --base-sha is passed, but that's always how CI is calling it.

Fixes flutter/flutter#79823 (and version checks in general)

This makes a number of changes:
- Fixes it to work without --base-sha
- Adds tests that it works in that mode
  - And tightens existing tests to require ToolExit, not just any error, to reduce false-positive test success
- Adds verbose logging of the checks being done, to make it easier to debug this kind of issue in the future
- Tightens the exception handling for missing previous versions to just the line that's expected to fail in that case
- Only allows missing versions when "publish_to: none" is set
  - Adds that everywhere it's missing
  - Standardize the format in the repo to "none" (instead of also having "'none'").
- Allows the use of NEXT in CHANGELOG as a way of gathering changes that are worth noting, but not
  doing a publish cycle for. (Replaces the plan of using -dev versions, since that's actually harder to implement,
  and more confusing.)
  - Ensures that we don't forget to clean up NEXT entries when bumping versions
  • Loading branch information
stuartmorgan authored Apr 8, 2021
1 parent d5ebaa5 commit 89ccc0e
Show file tree
Hide file tree
Showing 46 changed files with 331 additions and 96 deletions.
1 change: 1 addition & 0 deletions packages/android_alarm_manager/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: android_alarm_manager_example
description: Demonstrates how to use the android_alarm_manager plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/android_intent/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: android_intent_example
description: Demonstrates how to use the android_intent plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/battery/battery/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: battery_example
description: Demonstrates how to use the battery plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/camera/camera/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: camera_example
description: Demonstrates how to use the camera plugin.
publish_to: none

dependencies:
camera:
Expand Down
1 change: 1 addition & 0 deletions packages/connectivity/connectivity/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: connectivity_example
description: Demonstrates how to use the connectivity plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: connectivity_example
description: Demonstrates how to use the connectivity plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/device_info/device_info/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: device_info_example
description: Demonstrates how to use the device_info plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AndroidDeviceInfo {
required this.isPhysicalDevice,
required this.androidId,
required List<String> systemFeatures,
}) : supported32BitAbis = List<String>.unmodifiable(supported32BitAbis),
}) : supported32BitAbis = List<String>.unmodifiable(supported32BitAbis),
supported64BitAbis = List<String>.unmodifiable(supported64BitAbis),
supportedAbis = List<String>.unmodifiable(supportedAbis),
systemFeatures = List<String>.unmodifiable(systemFeatures);
Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: espresso_example
description: Demonstrates how to use the espresso plugin.
publish_to: 'none'
publish_to: none

environment:
sdk: ">=2.12.0-259.9.beta <3.0.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/file_selector/file_selector/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: example
description: A new Flutter project.

publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: none

version: 1.0.0+1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: flutter_plugin_android_lifecycle_example
description: Demonstrates how to use the flutter_plugin_android_lifecycle plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: google_maps_flutter_example
description: Demonstrates how to use the google_maps_flutter plugin.
publish_to: none

environment:
sdk: '>=2.12.0-259.9.beta <3.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CirclesController extends GeometryController {
/// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers.
CirclesController({
required StreamController<MapEvent> stream,
}) : _streamController = stream,
}) : _streamController = stream,
_circleIdToController = Map<CircleId, CircleController>();

/// Returns the cache of [CircleController]s. Test only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MarkersController extends GeometryController {
/// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers.
MarkersController({
required StreamController<MapEvent> stream,
}) : _streamController = stream,
}) : _streamController = stream,
_markerIdToController = Map<MarkerId, MarkerController>();

/// Returns the cache of [MarkerController]s. Test only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PolygonsController extends GeometryController {
/// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers.
PolygonsController({
required StreamController<MapEvent> stream,
}) : _streamController = stream,
}) : _streamController = stream,
_polygonIdToController = Map<PolygonId, PolygonController>();

/// Returns the cache of [PolygonController]s. Test only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PolylinesController extends GeometryController {
/// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers.
PolylinesController({
required StreamController<MapEvent> stream,
}) : _streamController = stream,
}) : _streamController = stream,
_polylineIdToController = Map<PolylineId, PolylineController>();

/// Returns the cache of [PolylineContrller]s. Test only.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: google_sign_in_example
description: Example of Google Sign-In plugin.
publish_to: none

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: image_picker_example
description: Demonstrates how to use the image_picker plugin.
author: Flutter Team <[email protected]>
publish_to: none

dependencies:
video_player: ^2.0.0-nullsafety.7
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: in_app_purchase_example
description: Demonstrates how to use the in_app_purchase plugin.
author: Flutter Team <[email protected]>
publish_to: none

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion packages/integration_test/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: integration_test_example
description: Demonstrates how to use the integration_test plugin.
publish_to: 'none'
publish_to: none

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/ios_platform_images/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ios_platform_images_example
description: Demonstrates how to use the ios_platform_images plugin.
publish_to: 'none'
publish_to: none
homepage: https://github.com/flutter/plugins/tree/master/packages/ios_platform_images/ios_platform_images

environment:
Expand Down
1 change: 1 addition & 0 deletions packages/local_auth/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: local_auth_example
description: Demonstrates how to use the local_auth plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/package_info/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: package_info_example
description: Demonstrates how to use the package_info plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/path_provider/path_provider/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: path_provider_example
description: Demonstrates how to use the path_provider plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: path_provider_example
description: Demonstrates how to use the path_provider plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: path_provider_example
description: Demonstrates how to use the path_provider plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/quick_actions/quick_actions/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: quick_actions_example
description: Demonstrates how to use the quick_actions plugin.
publish_to: none

dependencies:
flutter:
Expand Down
8 changes: 4 additions & 4 deletions packages/sensors/example/lib/snake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class SnakeState extends State<Snake> {
final math.Point<int>? newDirection = currentAcceleration == null
? null
: currentAcceleration.x.abs() < 1.0 && currentAcceleration.y.abs() < 1.0
? null
: (currentAcceleration.x.abs() < currentAcceleration.y.abs())
? math.Point<int>(0, currentAcceleration.y.sign.toInt())
: math.Point<int>(-currentAcceleration.x.sign.toInt(), 0);
? null
: (currentAcceleration.x.abs() < currentAcceleration.y.abs())
? math.Point<int>(0, currentAcceleration.y.sign.toInt())
: math.Point<int>(-currentAcceleration.x.sign.toInt(), 0);
state.step(newDirection);
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/sensors/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: sensors_example
description: Demonstrates how to use the sensors plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 1 addition & 0 deletions packages/share/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: share_example
description: Demonstrates how to use the share plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: shared_preferences_example
description: Demonstrates how to use the shared_preferences plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: shared_preferences_linux_example
description: Demonstrates how to use the shared_preferences_linux plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: shared_preferences_example
description: Demonstrates how to use the shared_preferences plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: shared_preferences_windows_example
description: Demonstrates how to use the shared_preferences_windows plugin.
publish_to: none

environment:
sdk: ">=2.12.0-259.9.beta <3.0.0"
Expand Down
1 change: 1 addition & 0 deletions packages/url_launcher/url_launcher/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: url_launcher_example
description: Demonstrates how to use the url_launcher plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: url_launcher_example
description: Demonstrates how to use the url_launcher plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: url_launcher_example
description: Demonstrates how to use the url_launcher plugin.
publish_to: none

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: url_launcher_example
description: Demonstrates the Windows implementation of the url_launcher plugin.
publish_to: none

dependencies:
flutter:
Expand Down
1 change: 0 additions & 1 deletion packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: video_player_example
description: Demonstrates how to use the video_player plugin.
version: 0.0.1
publish_to: none

dependencies:
Expand Down
1 change: 1 addition & 0 deletions packages/webview_flutter/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: webview_flutter_example
description: Demonstrates how to use the webview_flutter plugin.
publish_to: none

environment:
sdk: ">=2.12.0-259.9.beta <3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/webview_flutter/lib/webview_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class JavascriptChannel {
JavascriptChannel({
required this.name,
required this.onMessageReceived,
}) : assert(name != null),
}) : assert(name != null),
assert(onMessageReceived != null),
assert(_validChannelNames.hasMatch(name));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wifi_info_flutter_example
description: Demonstrates how to use the wifi_info_flutter plugin.
publish_to: 'none'
publish_to: none

environment:
sdk: ">=2.12.0-259.9.beta <3.0.0"
Expand Down
16 changes: 12 additions & 4 deletions script/tool/lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -596,10 +596,18 @@ class GitVersionFinder {
return changedFiles.toList();
}

/// Get the package version specified in the pubspec file in `pubspecPath` and at the revision of `gitRef`.
Future<Version> getPackageVersion(String pubspecPath, String gitRef) async {
final io.ProcessResult gitShow =
await baseGitDir.runCommand(<String>['show', '$gitRef:$pubspecPath']);
/// Get the package version specified in the pubspec file in `pubspecPath` and
/// at the revision of `gitRef` (defaulting to the base if not provided).
Future<Version> getPackageVersion(String pubspecPath, {String gitRef}) async {
final String ref = gitRef ?? (await _getBaseSha());

io.ProcessResult gitShow;
try {
gitShow =
await baseGitDir.runCommand(<String>['show', '$ref:$pubspecPath']);
} on io.ProcessException {
return null;
}
final String fileContent = gitShow.stdout as String;
final String versionString = loadYaml(fileContent)['version'] as String;
return versionString == null ? null : Version.parse(versionString);
Expand Down
Loading

0 comments on commit 89ccc0e

Please sign in to comment.