0

このロジックを bash スクリプトに組み込みたい: 現在のリポジトリにローカルの変更がある場合に処理を停止します。

私は git にも同じロジックを持っています。

#!/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
4

1 に答える 1

1

これはそれを行う必要があります:

if [ -n "$(hg status -mar)" ]
then
    echo >&2 "error: your index contains uncommitted changes."
    exit 1
fi

これにより、移動、追加、または削除されたファイルがチェックされます。削除済み (行方不明) または不明だが無視されていないかどうかを確認したい場合は、それも可能です。

于 2013-06-07T00:36:47.653 に答える