From b3b9afa668e6f3d15db6474537ffec2ad29fb5c0 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 9 Jan 2021 17:30:41 -0500 Subject: [PATCH] checkPlugin: Split dirty working directory check into two checks Rather than check for modifications and untracked files in one command, use two commands: one for modifications and one for untracked files. This makes the error messages easier to understand, and it allows us to include `git status`-like output in the modifications error message. --- bin/plugins/checkPlugin.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/plugins/checkPlugin.js b/bin/plugins/checkPlugin.js index d71bb49e4..6483ef4be 100755 --- a/bin/plugins/checkPlugin.js +++ b/bin/plugins/checkPlugin.js @@ -51,8 +51,10 @@ const prepareRepo = () => { execSync('git rev-parse --verify -q HEAD^0 || ' + `{ echo "Error: no commits on ${branch}" >&2; exit 1; }`); execSync('git rev-parse --verify @{u}'); // Make sure there's a remote tracking branch. - const dirtyFiles = execSync('git ls-files -dmo --exclude-standard'); - if (dirtyFiles !== '') throw new Error(`working directory is unclean:\n${dirtyFiles}`); + const modified = execSync('git diff-files --name-status'); + if (modified !== '') throw new Error(`working directory has modifications:\n${modified}`); + const untracked = execSync('git ls-files -o --exclude-standard'); + if (untracked !== '') throw new Error(`working directory has untracked files:\n${untracked}`); const indexStatus = execSync('git diff-index --cached --name-status HEAD'); if (indexStatus !== '') throw new Error(`uncommitted staged changes to files:\n${indexStatus}`); execSync('git pull --ff-only', {stdio: 'inherit'});