cleartool 发现某些文件类型与前任递归的差异

cleartool find difference recursive in certain file type to predecessor

在我的脚本中,我调用 ClearCase 来检查当前路径(包括所有子文件夹)中某种文件类型的任何文件是否已被更改。我根本不熟悉 cleartool,命令应该是这样的:

cleartool diff -predecessor -recursive *.filetype

作为 return 值,我只需要一个布尔值:如果存在任何差异则为真,如果没有任何变化则为假

乍一看,您要查找的命令是这样的:

cleartool find . -name "*.filetype" -exec 'cleartool diff -pred "$CLEARCASE_PN"'

在 windows 上,它看起来像这样:

cleartool find . -name "*.filetype" -exec "cleartool diff -pred \"%CLEARCASE_PN%\""

Unix 示例中的单引号很重要,否则 "CLEARCASE_PN" 环境变量引用将在您启动命令时展开,而不是在实际触发 -exec 时展开。

Windows 命令行中的 \"%CLEARCASE_PN%\" 构造和 unix 上的 "$CLEARCASE_PN" 是为了考虑包括空格的文件名。

现在,看看你想要什么......我不确定它是否能实现根本目的,不管是什么。

As a return value I only need a bool: true if any differences exist, false if nothing has changed

你需要一个脚本。一个简单的 find + exec 是不够的,因为退出状态将不是您所需要的。

#! /bin/bash
noChange=0  ### "cleartool diff" exit status means no difference
files=$(cleartool find . -name "*.filetype")
for f in ${file}; do;
  cleartool diff -pre -options "-status_only" "${f}"
  if [ $? != $noChange ]; then
    exit 0
  fi
done
exit 1

(0 is true, false is 1 in shell)

注意 -options 参数的 cleartool diff 中的用法:

opt/ions pass-through-opts

Specifies one or more compare method options that are not directly supported by diff.

这样,您只能从 cleartool diff 获得状态,这正是您要在您的案例中测试的状态。

由于您的 显示您也有 Git,您可以轻松地在 bash 会话中执行该脚本,甚至在 Windows.