forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathincremental_build.sh
More file actions
executable file
·35 lines (29 loc) · 1.37 KB
/
incremental_build.sh
File metadata and controls
executable file
·35 lines (29 loc) · 1.37 KB
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
#!/bin/bash
set -ev
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [ "${BRANCH_NAME}" = "master" ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@" $PLUGIN_SHARDING
else
# Make sure there is up-to-date master.
git fetch origin master
FLUTTER_CHANGED_GLOBAL=0
FLUTTER_CHANGED_PACKAGES=""
# Try get a merge base for the branch and calculate affected packages.
# We need this check because some CIs can do a single branch clones with a limited history of commits.
if BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD); then
echo "Checking changes from $BRANCH_BASE_SHA..."
FLUTTER_CHANGED_GLOBAL=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -v packages | wc -l`
FLUTTER_CHANGED_PACKAGES=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq | paste -s -d, -`
else
echo "Cannot find a merge base for the current branch to run an incremental build..."
echo "Please rebase your branch onto the latest master!"
fi
if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@" $PLUGIN_SHARDING
else
echo "Running only for $FLUTTER_CHANGED_PACKAGES"
pub global run flutter_plugin_tools "$@" --plugins=$FLUTTER_CHANGED_PACKAGES
fi
fi