【问题标题】:How to find out if there are any not committed or pushed changes to a mercurial repository from bash?如何找出是否有任何未提交或从 bash 推送到 mercurial 存储库的更改?
【发布时间】:2013-06-06 13:38:55
【问题描述】:

我想将此逻辑合并到 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

【问题讨论】:

    标签: mercurial diff


    【解决方案1】:

    应该这样做:

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

    检查是否有任何文件被移动、添加或删除。如果您想检查已删除(缺失)或未知但未被忽略,您也可以这样做。

    【讨论】:

    • 我确实想检查所有内容,包括已删除的文件,甚至是未推送到上层存储库的已提交文件。我需要确保当此操作成功时,我确实拥有远程存储库的完美副本,因为我想将此作为推送发布的要求。
    猜你喜欢
    • 1970-01-01
    • 2011-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-28
    • 2011-06-24
    • 2014-05-09
    相关资源
    最近更新 更多