Skip to content

Commit

Permalink
Make restyle-diff pick a better base to restyle against (#25887)
Browse files Browse the repository at this point in the history
- Default to upstream/master if upstream exists
- Use --merge-base to restrict to files changes on current branch
  • Loading branch information
ksperling-apple authored and pull[bot] committed Nov 28, 2023
1 parent edf78f8 commit 1195951
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/helpers/restyle-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
# Usage:
# restyle-diff.sh [ref]
#
# if unspecified, ref defaults to "master"
# if unspecified, ref defaults to upstream/master (or master)
#

here=${0%/*}

set -e

CHIP_ROOT=$(cd "$here/../.." && pwd)
cd "$CHIP_ROOT"

restyle-paths() {
if hash restyle-path 2>/dev/null; then
Expand All @@ -41,7 +42,11 @@ restyle-paths() {
fi
}

cd "$CHIP_ROOT"
declare -a paths="($(git diff --ignore-submodules --name-only "${1:-master}"))"
ref="$1"
if [[ -z "$ref" ]]; then
ref="master"
git remote | grep -qxF upstream && ref="upstream/master"
fi

declare -a paths="($(git diff --ignore-submodules --name-only --merge-base "$ref"))"
restyle-paths "${paths[@]}"

0 comments on commit 1195951

Please sign in to comment.