dart.fetch-dart-deps: Verify the pubspec.lock as well as pubspec.yaml

88275ca6d6 inadvertently stopped the pubspec.lock from changing, as it copied the file before running pub get.

pub get can modify the pubspec.lock to update it to newer formats (for example by adding hashes and updating URLs, see an example diff below). We do not need the modifications at any later stage, so we can preserve the original file.

      boolean_selector:
        dependency: transitive
        description:
          name: boolean_selector
    +      sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
    +      url: "https://pub.dev"
    -      url: "https://pub.dartlang.org"
        source: hosted
    +    version: "2.1.1"
    -    version: "2.1.0"
This commit is contained in:
hacker1024 2023-04-16 03:20:36 +10:00
parent 396938b6de
commit 5fa3b41041

View File

@ -29,18 +29,13 @@ _setupPubCache() {
done
# ensure we're using a lockfile for the right package version
if [ -e pubspec.lock ]; then
# FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things.
# diff -u pubspec.lock "$deps/pubspec/pubspec.lock"
true
else
if [ ! -e pubspec.lock ]; then
cp -v "$deps/pubspec/pubspec.lock" .
# Sometimes the pubspec.lock will get opened in write mode, even when offline.
chmod u+w pubspec.lock
fi
if ! diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml"; then
echo 1>&2 -e 'The pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \
elif [ ! { diff -u pubspec.lock "$deps/pubspec/pubspec.lock" && diff -u pubspec.yaml "$deps/pubspec/pubspec.yaml" } ]; then
echo 1>&2 -e 'The pubspec.lock or pubspec.yaml of the project derivation differs from the one in the dependency derivation.' \
'\nYou most likely forgot to update the vendorHash while updating the sources.'
exit 1
exit 1
fi
}