nodegit

2025-12-11 0 532

nodegit

节点绑定与libgit2项目。

稳定(libgit2@v0.28.3):0.28.3

有问题吗?来和我们聊天!

请访问slack.libgit2.org注册,然后加入我们的nodegit 。

维护

泰勒·安·瓦尼克(Tyler Ang-Wanek)@Twwanek在大量出色的贡献者的帮助下!

校友维护者

Tim Branyen @Tbranyen,John Haley @Johnhaley81,Max Korp @maxkorp,Steve Smith @orderedlist,Michael Robinson @codeofinterest和Nick Kallen @NK

API文档。

http://www.*node*g*it.org/

入门。

nodegit将在大多数开箱即用,而无需任何本机依赖。

npm install nodegit

如果您收到有关libstdc ++的错误,这些错误通常是在Travis-CI上构建时经历的,则可以通过升级到最新的LIBSTDC ++ -4.9来解决此问题。

在Ubuntu:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-dev

在特拉维斯:

 addons :
  apt :
    sources :
      - ubuntu-toolchain-r-test
    packages :
      - libstdc++-4.9-dev

在Circleci:

  dependencies :
    pre :
      - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
      - sudo apt-get update
      - sudo apt-get install -y libstdc++-4.9-dev

如果您收到有关LifeCycleScript的错误,请启动/安装,您可能会错过Ubuntu中的Libssl-Dev

sudo apt-get install libssl-dev

您需要在Linux机上安装以下库:

  • libpcre
  • libpcreposix
  • libkrb5
  • libk5crypto
  • libcom_err

在本地构建时,您还需要Kerberos和PCRE的开发包,因此机器上必须存在这两个公用事业:

  • pcre-config
  • Krb5-Config

如果您在安装时仍遇到问题,则应从源说明中尝试建筑物。

API示例。

克隆存储库并读取文件:

nodegit\”);

// Clone a given repository into the `./tmp` folder.
Git.Clone(\”https://*github.*c*om/nodegit/ nodegit \”, \”./tmp\”)
// Look up this known commit.
.then(function(repo) {
// Use a known commit sha from this repository.
return repo.getCommit(\”59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5\”);
})
// Look up a specific file within that commit.
.then(function(commit) {
return commit.getEntry(\”README.md\”);
})
// Get the blob contents from the file.
.then(function(entry) {
// Patch the blob to contain a reference to the entry.
return entry.getBlob().then(function(blob) {
blob.entry = entry;
return blob;
});
})
// Display information about the blob.
.then(function(blob) {
// Show the path, sha, and filesize in bytes.
console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + \”b\”);

// Show a spacer.
console.log(Array(72).join(\”=\”) + \”\\n\\n\”);

// Show the entire file.
console.log(String(blob));
})
.catch(function(err) { console.log(err); });
\”>

 var Git = require ( \" nodegit \" ) ;

// Clone a given repository into the `./tmp` folder.
Git . Clone ( \"https://*github.*c*om/nodegit/ nodegit \" , \"./tmp\" )
  // Look up this known commit.
  . then ( function ( repo ) {
    // Use a known commit sha from this repository.
    return repo . getCommit ( \"59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5\" ) ;
  } )
  // Look up a specific file within that commit.
  . then ( function ( commit ) {
    return commit . getEntry ( \"README.md\" ) ;
  } )
  // Get the blob contents from the file.
  . then ( function ( entry ) {
    // Patch the blob to contain a reference to the entry.
    return entry . getBlob ( ) . then ( function ( blob ) {
      blob . entry = entry ;
      return blob ;
    } ) ;
  } )
  // Display information about the blob.
  . then ( function ( blob ) {
    // Show the path, sha, and filesize in bytes.
    console . log ( blob . entry . path ( ) + blob . entry . sha ( ) + blob . rawsize ( ) + \"b\" ) ;

    // Show a spacer.
    console . log ( Array ( 72 ) . join ( \"=\" ) + \"\\n\\n\" ) ;

    // Show the entire file.
    console . log ( String ( blob ) ) ;
  } )
  . catch ( function ( err ) { console . log ( err ) ; } ) ;

模拟git日志:

nodegit\”);

// Open the repository directory.
Git.Repository.open(\”tmp\”)
// Open the master branch.
.then(function(repo) {
return repo.getMasterCommit();
})
// Display information about commits on master.
.then(function(firstCommitOnMaster) {
// Create a new history event emitter.
var history = firstCommitOnMaster.history();

// Create a counter to only show up to 9 entries.
var count = 0;

// Listen for commit events from the history.
history.on(\”commit\”, function(commit) {
// Disregard commits past 9.
if (++count >= 9) {
return;
}

// Show the commit sha.
console.log(\”commit \” + commit.sha());

// Store the author object.
var author = commit.author();

// Display author information.
console.log(\”Author:\\t\” + author.name() + \” <\” + author.email() + \”>\”);

// Show the commit date.
console.log(\”Date:\\t\” + commit.date());

// Give some space and show the message.
console.log(\”\\n \” + commit.message());
});

// Start emitting events.
history.start();
});\”>

 var Git = require ( \" nodegit \" ) ;

// Open the repository directory.
Git . Repository . open ( \"tmp\" )
  // Open the master branch.
  . then ( function ( repo ) {
    return repo . getMasterCommit ( ) ;
  } )
  // Display information about commits on master.
  . then ( function ( firstCommitOnMaster ) {
    // Create a new history event emitter.
    var history = firstCommitOnMaster . history ( ) ;

    // Create a counter to only show up to 9 entries.
    var count = 0 ;

    // Listen for commit events from the history.
    history . on ( \"commit\" , function ( commit ) {
      // Disregard commits past 9.
      if ( ++ count >= 9 ) {
        return ;
      }

      // Show the commit sha.
      console . log ( \"commit \" + commit . sha ( ) ) ;

      // Store the author object.
      var author = commit . author ( ) ;

      // Display author information.
      console . log ( \"Author:\\t\" + author . name ( ) + \" <\" + author . email ( ) + \">\" ) ;

      // Show the commit date.
      console . log ( \"Date:\\t\" + commit . date ( ) ) ;

      // Give some space and show the message.
      console . log ( \"\\n    \" + commit . message ( ) ) ;
    } ) ;

    // Start emitting events.
    history . start ( ) ;
  } ) ;

有关更多示例,请检查示例/文件夹。

单位测试。

在进行测试之前,您需要在本地建立。见上文。

npm test

下载源码

通过命令行克隆项目:

git clone https://github.com/nodegit/nodegit.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 编程相关 nodegit https://www.zuozi.net/33879.html

learnopencv
上一篇: learnopencv
gpt crawler
下一篇: gpt crawler
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务