-
Notifications
You must be signed in to change notification settings - Fork 41
/
use-latest-deps-flutter.sh
executable file
·78 lines (67 loc) · 1.89 KB
/
use-latest-deps-flutter.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
print_usage () {
(>&2 echo "Usage:")
(>&2 echo " $0 [-d] github-user/repository-name")
(>&2 echo "Arguments:")
(>&2 echo " -d: do a dry-run. Don't push or send a PR.")
}
# Check for optional arguments.
DRYRUN=0
while getopts :d opt; do
case $opt in
d)
(>&2 echo "Entered dry-run mode.")
DRYRUN=1
;;
\?)
(>&2 echo "Got invalid option -$OPTARG.")
print_usage
exit 1
;;
esac
done
shift $((OPTIND-1))
# Check that positional arguments are set.
if [[ -z $1 ]] ; then
(>&2 echo "Missing repo argument.")
print_usage
exit 1
fi
if [[ "$1" != *"/"* ]] ; then
(>&2 echo "Repo argument needs to be of form username/repo-name.")
print_usage
exit 1
fi
REPO=$1
# Get this script's directory.
# http://stackoverflow.com/a/246128/101923
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
## Install Flutter
git clone https://github.com/flutter/flutter.git --depth 1 -b stable "${DIR}/_flutter"
PATH="${PATH}:${DIR}/_flutter/bin"
set -e
set -x
# Find and update each pubspec.yml
find . -iname pubspec.yaml -execdir flutter pub upgrade \;
# If there were any changes, test them and then push and send a PR.
set +e
if ! git diff --quiet; then
if [[ "$DRYRUN" -eq 0 ]] ; then
set -e
"${DIR}/commit-and-push.sh"
"${DIR}/send-pr.sh" "$REPO"
fi
fi