从git diff命令结果中获取JSON内容。

huangapple go评论53阅读模式
英文:

Fetching json content from a git diff command result

问题

Sure, here's the translation of the content you provided:

Git diff tag1.2 tag1.5

上述命令的输出为

**标签
一些字符
@@262728
{
'Code-version':'1.5',
'changes':[
'code-repo':'2.1']
}
**标签
一些字符
@@262728
{
'Code-version':'1.4',
'changes':[
'code-repo':'2.0']
}
**标签
一些字符
@@262728
{
'Code-version':'1.3',
'changes':[
'code-repo':'1.9']
}


我需要仅显示最新的 JSON 内容,如下所示,不包括其他不需要的内容

{
'Code-version':'1.5'
'changes':[
'code-repo':'2.1']
}

英文:
Git diff tag1.2 tag1.5

Output for the above command is

**Tag
Some character
@@262728
{
'Code-version':'1.5',
'changes':[
'code-repo':'2.1']
}
**Tag
Some character
@@262728
{
'Code-version':'1.4',
'changes':[
'code-repo':'2.0']
}
**Tag
Some character
@@262728
{
'Code-version':'1.3',
'changes':[
'code-repo':'1.9']
}

I need to display only the latest json content like below excluding other unwanted stuffs

{
'Code-version':'1.5'
'changes':[
'code-repo':'2.1']
}

答案1

得分: 1

如果您对特定标签(或提交)下文件的内容感兴趣,您可以使用 git show 命令:

git show 标签名:路径/至/文件

git diff 显示文件的两个不同版本之间的差异,但您只关心文件的一个特定版本。

英文:

If you are interested in the content of a file at a specific tag (or commit), you can use git show:

git show tagname:path/to/file

git diff shows the difference between two revisions of a file, but you are only interested in one specific version of the file.

huangapple
  • 本文由 发表于 2023年5月17日 17:18:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270459.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定