Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: tools/clang-format-js

Issue 2618623002: Fix clang-format-js to only include repo files (Closed)
Patch Set: fix something at least Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang-format-js
diff --git a/tools/clang-format-js b/tools/clang-format-js
index 4b04d8dc79809dc5d5b1404edc5c2fa5ca048c9a..b8a92b53a255a3e7457f29970f99a5f7973c425a 100755
--- a/tools/clang-format-js
+++ b/tools/clang-format-js
@@ -4,30 +4,37 @@
# found in the LICENSE file.
if [[ -z "${@}" ]]; then
- echo >&2 "Usage: `basename $0` <paths_to_clang_format...>";
- exit 1;
+ echo >&2 "Usage: `basename $0` <paths_to_clang_format...>"
+ exit 1
fi
-which clang-format >/dev/null 2>&1;
+which clang-format >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
- echo >&2 "Sorry, but you need \`clang-format\` on your \$PATH to run this script";
- exit 1;
+ echo >&2 "Sorry, but you need \`clang-format\` on your \$PATH to run this script"
+ exit 1
fi
-for arg in "${@}"; do
+for arg in ${@}; do
+ echo "Processing ${arg}"
+
dir=`readlink -f "${arg}"`
if [[ -d "${dir}" ]]; then
dir="${dir}/stripped-by-dirname-on-next-line"
fi
while dir=`dirname ${dir}`; do
if [[ -f "${dir}/.clang-format" ]]; then
- echo "Using style from: ${dir}/.clang-format";
- break;
+ echo "Using style from: ${dir}/.clang-format"
+ break
elif [[ "${dir}" == "/" ]]; then
- echo >&2 "No .clang-format file found. Make one at or above ${arg}";
- exit 1;
+ echo >&2 "No .clang-format file found. Make one at or above ${arg}"
+ exit 1
fi
done
-done
-find "${@}" -type f -iname '*.js' | xargs clang-format -i -style=file;
+ js_files=$(git ls-tree -r --name-only HEAD -- "${arg}" | grep '\.js$')
+
+ for js_file in ${js_files}; do
+ echo "Formatting ${js_file}"
+ clang-format -i -style=file "$js_file"
+ done
+done
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698