Skip to content

Commit

Permalink
optimize-png-files.sh: relax cwd restriction
Browse files Browse the repository at this point in the history
There's nothing in this script that really requires being run in the
top level of the src.git repo other than the git commit logic.  That
means we can run this script completely outside of src.git if given
a set of paths to operate on.  Move the check into the git scenario.

Bug: None
Test: ran the script outside of src.git on some png files
Change-Id: I4d1343f3757a05e8675ac80c618c8b4ec23e1695
Reviewed-on: https://chromium-review.googlesource.com/1097615
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566690}
  • Loading branch information
vapier authored and Commit Bot committed Jun 13, 2018
1 parent bc67c04 commit 0424f1a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tools/resources/optimize-png-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,6 @@ Options:
exit 1
}

if [ ! -e ../.gclient ]; then
echo "$0 must be run in src directory"
exit 1
fi

if [ "$(expr substr $(uname -s) 1 6)" == "CYGWIN" ]; then
using_cygwin=true
else
Expand Down Expand Up @@ -512,6 +507,12 @@ set ${DIRS:=$ALL_DIRS}
info "Optimize level=$OPTIMIZE_LEVEL"

if [ -n "$COMMIT" ] ; then
# To keep git logic below sane, require it be run from the top dir.
if [ ! -e ../.gclient ]; then
echo "$0 must be run in src directory"
exit 1
fi

ALL_FILES=$(git diff --name-only $COMMIT HEAD $DIRS | grep "png$")
ALL_FILES_LIST=( $ALL_FILES )
echo "Processing ${#ALL_FILES_LIST[*]} files"
Expand Down

0 comments on commit 0424f1a

Please sign in to comment.