使用 power shell 从 git show 中执行 id



我有以下来自 GIT 节目的输入:

commit d5089c3135e104c2b508fe58d98596c96b2ae19a Merge: bd82ec4 d36607b Author:  Thomas <thomas@gmail> Date:   Fri Feb 7 18:48:38 2020 +0000      Merged in test_cicd (pull request #93)          PIS-504     id="VN.P.1.0.1"

我需要解析id,然后保存到变量中。 EX : VN.P.1.0.1

我的代码是

$build = git  show
$id = if ($build -match 'bid=("d"+)b') { $Matches[1] }

但不工作..帮助任何人?

找到用双引号括起来的id后,获取所有内容而不是双引号:

$id = if ($build -match 'bid="([^"]+)"') { $Matches[1] }
# this                          ^^^^^ 

更新:根据注释,猜测实际git输出与OP示例中显示的不同。替换为s空格字符单词边界元字符。

最新更新