[英]How can I get the contents of a file of a git commit with the gift library?
I am using the https://github.com/notatestuser/gift
library and here's what I have: 我正在使用https://github.com/notatestuser/gift
库,这是我所拥有的:
gitCommit.tree().contents (err, gitTreeContents) ->
console.log gitTreeContents
This gives me the tree contents, which is an array with objects that look like: 这给了我树的内容,它是一个包含对象的数组,如下所示:
{ repo:
{ path: '/mygitrepo',
bare: false,
dot_git: '/mygitrepo/.git',
git:
{ [Function]
cmd: [Function],
streamCmd: [Function],
list_remotes: [Function],
refs: [Function] } },
id: 'ed38d79b10503a4e7e68910f37f387f24dedd5fa',
name: 'address.js',
mode: '100644' }
So two questions. 有两个问题。 First, what is that id
referring to? 首先,该id
指的是什么? It's not a commit sha, so I assume it's a treeish? 它不是提交区,所以我认为它是树状的? Second, how can I see what the file looked like at that point in time? 第二,如何查看该时间点的文件?
Thanks 谢谢
gift
is a simple wrapper over command line git. gift
是命令行git的简单包装。 In command line git you should run a command like this: git cat-file blob <commit-sha-1>:</path/to/file>
. 在命令行git中,您应该运行如下命令: git cat-file blob <commit-sha-1>:</path/to/file>
。 Take a look at http://github.com/notatestuser/gift/blob/master/src/blob.coffee it seems, it does exactly what you need. 看一下http://github.com/notatestuser/gift/blob/master/src/blob.coffee,它看起来确实满足您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.