Skip to content

Commit 81ef8e4

Browse files
fkorotkovgoderbauer
authored andcommitted
Don't fail an incremental build if can't find a merge base (flutter#444)
1 parent a76fc24 commit 81ef8e4

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

script/incremental_build.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@ if [ "${BRANCH_NAME}" = "master" ]; then
1010
else
1111
# Make sure there is up-to-date master.
1212
git fetch origin master
13-
BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD)
14-
echo "Checking changes from $BRANCH_BASE_SHA..."
15-
FLUTTER_CHANGED_GLOBAL=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -v packages | wc -l`
16-
FLUTTER_CHANGED_PACKAGES=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq | paste -s -d, -`
13+
14+
FLUTTER_CHANGED_GLOBAL=0
15+
FLUTTER_CHANGED_PACKAGES=""
16+
17+
# Try get a merge base for the branch and calculate affected packages.
18+
# We need this check because some CIs can do a single branch clones with a limited history of commits.
19+
if BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD); then
20+
echo "Checking changes from $BRANCH_BASE_SHA..."
21+
FLUTTER_CHANGED_GLOBAL=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -v packages | wc -l`
22+
FLUTTER_CHANGED_PACKAGES=`git diff --name-only $BRANCH_BASE_SHA HEAD | grep -o "packages/[^/]*" | sed -e "s/packages\///g" | sort | uniq | paste -s -d, -`
23+
else
24+
echo "Cannot find a merge base for the current branch to run an incremental build..."
25+
echo "Please rebase your branch onto the latest master!"
26+
fi
27+
1728
if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
1829
echo "Running for all packages"
1930
pub global run flutter_plugin_tools "$@"

0 commit comments

Comments
 (0)