Skip to content

Commit 48e3f49

Browse files
committed
feat(tools): support Sapling in code formatter
Some tools, such as tools/format, ask Git for a list of files to operate on. If a contributor is not using Git, these tools fail. Support the Sapling VCS in tools/format by falling back to 'sl files' if 'git ls-files' fails.
1 parent bc8769b commit 48e3f49

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tools/files.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44
# This file is a library used by other script. Do not execute this file
55
# directly.
66

7+
find_repo_files() {
8+
if git ls-files --cached --exclude-standard -- "${@}" 2>/dev/null; then
9+
return
10+
fi
11+
if sl files "${@}" 2>/dev/null; then
12+
return
13+
fi
14+
printf "error: could not run 'git ls-files' or 'sl files'\n'" >&2
15+
return 1
16+
}
17+
718
find_non_vendor_files() {
8-
git ls-files --cached --exclude-standard -- "${@}" \
19+
find_repo_files "${@}" \
920
| { grep -v '^vendor/.*/' || true ; } \
1021
| {
1122
while read path ; do

0 commit comments

Comments
 (0)