NodeJs
NodeJs - 在Windows上访问Git索引(NodeJs - Access Git index on Windows)我正在尝试使用nodejs模块, 礼物来读取Git repo的索引。 我之所以选择'礼物'是因为它似乎是Windows上最有前途的。 有谁知道如何使用此模块获取Git仓库的状态? 我基本上只想在我的Git仓库上执行状态命令。
$ git状态
还有其他nodejs Git模块在Windows上运行良好吗?
谢谢!
解
在查看源代码后,我发现Status是一个附加到Repo的对象。 您可以按照我选择的答案中的描述使用它。
Windows警告 - 我必须将git添加到我的系统路径然后重新启动。 得爱windows:\即使将git添加到我的系统路径并在cmd.exe中测试它,礼物仍然抛出错误:
命令失败:'git'不被识别为内部或外部命令,可操作程序或批处理文件。
一旦我重新启动一切都很好。
I am trying to use the nodejs module, gift to read the index of a Git repo. I chose 'gift' because it seemed the most promising on Windows. Does anyone know how to get the status of the Git repo using this module? I basically just want to perform a status command on my Git repo.
$ git status
Are there any other nodejs Git Modules that work well on Windows?
Thanks!
Solution
After looking through the source I found that Status is an object which is attached to Repo. You use it as described in my selected answer.
Windows caveat - I had to add git to my system path and then REBOOT. Gotta love windows :\ Even after adding git to my system path and testing it out in cmd.exe, gift kept throwing error:
command failed: 'git' is not recognized as an internal or external command, operable program or batch file.
Once I rebooted all was well.
最满意答案你可以得到这样的状态
git = require 'gift'repo = git "path/to/repo"repo.status(callback)回调接收(err, status) 。 状态具有属性
status.cleanboolean,如果工作树清理,则为true
status.files对象 - 键是文件,值对象指示文件是否被暂存,跟踪等。
每个文件都具有以下属性:
type - “A”表示已添加,“M”表示已修改,“D”表示已删除。 staged - 布尔值 tracked - 布尔值此信息的来源: 文档 。
You can get the status like this
git = require 'gift'repo = git "path/to/repo"repo.status(callback)The callback receives (err, status). Status has properties
status.cleanboolean, true if working tree clean
status.filesObject - The keys are files, the values objects indicating whether or not the file is staged, tracked, etc.
Each file has the following properties:
type - "A" for added, "M" for modified, "D" for deleted. staged - Boolean tracked - BooleanSource for this information: the documentation.