1

如果您的 git repo 不是最新的 master(git fetch --dry-run 有输出),我将如何制作一个引发错误的目标?

4

2 回答 2

1

主要从字面上理解您的要求:

up-to-date:
    [[ -z "$(git fetch --dry-run)" ]]
于 2013-11-08T18:20:55.303 回答
0

您可能不想完全在makefile. 编写类似这样的脚本(调用它repo_is_current.sh)会更容易一些:

#!/bin/bash
local_master=$(git rev-parse refs/heads/master)
remote_master=$(git ls-remote origin master | cut -f 1)
if [[ "${local_mater}" == "${remote_master}" ]]
then
  exit 0
fi
exit 1

然后创建一个makefile调用它的目标:

uptodate:
        ./repo_is_current.sh

并确保您的主要目标将此作为其第一个先决条件:

all: uptodate other targets go here
于 2013-11-08T18:46:37.280 回答