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

Don't fail an incremental build if can't find a merge base #444

Merged
merged 3 commits into from
Apr 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions script/incremental_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,20 @@ if [ "${BRANCH_NAME}" = "master" ]; then
else
# Make sure there is up-to-date master.
git fetch origin master
BRANCH_BASE_SHA=$(git merge-base --fork-point FETCH_HEAD HEAD)
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, -`

FLUTTER_CHANGED_GLOBAL=0
FLUTTER_CHANGED_GLOBAL=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional to first assign 0 and then empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! It's a typo. It suppose to be FLUTTER_CHANGED_PACKAGES. Updated the PR.


# 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!"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add to this message what would be required to make the build incremental (e.g. rebase, maybe?)?

fi

if [ "${FLUTTER_CHANGED_PACKAGES}" = "" ] || [ $FLUTTER_CHANGED_GLOBAL -gt 0 ]; then
echo "Running for all packages"
pub global run flutter_plugin_tools "$@"
Expand Down