有没有人使用 nodejs 实现过 git clone 或接口库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5955891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 14:09:49  来源:igfitidea点击:

Has anyone implemented a git clone or interface library using nodejs?

gitnode.js

提问by blueberryfields

I'm looking for an implementation of git which is accessible from nodejs - does such a beast exist?

我正在寻找可从 nodejs 访问的 git 实现 - 这样的野兽存在吗?

采纳答案by dribnet

Looks like there are now several options for using git from node:

看起来现在有几个选项可以从节点使用 git:

  • gift: simple Node.js wrapper for the Git CLI with an API based on Grit (npm/ github)
  • node-git: a node.js git implementation modeled on grit (npm/ github)
  • nodegit: libgit2 asynchronous native bindings (npm/ github)
  • node-git: a thin wrapper around the command-line git command (github)
  • 礼物:Git CLI 的简单 Node.js 包装器,带有基于 Grit ( npm/ github)的 API
  • node-git:一个基于 grit ( npm/ github)建模的 node.js git 实现
  • nodegit:libgit2 异步本机绑定(npm/ github
  • node-git:命令行 git 命令(github)周围的薄包装器

回答by Mauvis Ledford

Note sure if there's a git library for Node but you can also just execute a shell process directly, example:

请注意是否有 Node 的 git 库,但您也可以直接执行 shell 进程,例如:

var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
exec("git status", puts);

回答by payload

there is also node-gittehas libgit2 bindings, but both gitteh and christkv/node-git were not of the quality and completeness I needed

还有node-gitteh作为 libgit2 绑定,但是 gitteh 和 christkv/node-git 都没有我需要的质量和完整性

I wrote treeeatera spawn git wrapper, which is callable with plain javascript objects instead of strings, can parse some output (git log → commit objects, git ls-tree → tree object hierachy) and runs async. It is in active use and supports all git commands, atleast for calling them and piping their output chunk or line wise. You can stick to git man-pages to get the documentation to each command.

我为treeeater 编写了一个 spawn git 包装器,它可以用普通的 javascript 对象而不是字符串调用,可以解析一些输出(git log → commit objects,git ls-tree → tree object hierachy)并异步运行。它正在积极使用并支持所有 git 命令,至少可以调用它们并按行输出块或行。你可以坚持使用 git man-pages 来获取每个命令的文档。