我想将此逻辑合并到 bash 脚本中:如果当前存储库有任何本地更改,则停止处理。
我对 git 有相同的逻辑,现在我需要为 mercurial:
#!/bin/bash
set -ex
git pull
git update
# Disallow unstaged changes in the working tree
if ! git diff-files --check --exit-code --ignore-submodules -- >&2
then
echo >&2 "error: you have unstaged changes."
exit 1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --exit-code -r --ignore-submodules HEAD -- >&2
then
echo >&2 "error: your index contains uncommitted changes."
exit 1
fi