簡體   English   中英

使用NodeGit讀取Git配置變量

[英]Reading Git config variable using NodeGit

NodeGit似乎沒有提供任何API來檢索Git配置值。

參見http://www.nodegit.org/#Config

我期望使用類似Config#getValue()或類似的API來檢索配置值。

也許到目前為止,由於libgit2具有這些API,它在NodeGit中尚不存在。

有什么提示嗎?

NodeGit當前不公開 libgit2 的配置功能 進入那里應該不難,但我不知道它是否會進入計划用於下一個版本的0.3.0版本。

我創建了一個問題 ,可以跟蹤是否需要更新進度。

這是獲取全局git config變量的示例:

var nodegit = require("nodegit");

nodegit.Config.openDefault()
  .then(function (config) {
    return config.getStringBuf('user.name');
  })
  .then(console.log);

這是獲取存儲庫配置變量的方法:

nodegit.Repository.open('PATH_TO_REPO')
  .then(function (repository) {
    return repository.config();
  })
  .then(function (config) {
    return config.getStringBuf('user.name');
  })
  .then(console.log);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM