【发布时间】:2022-02-08 23:48:31
【问题描述】:
我正在尝试Git-Describe npm 包来检索哈希信息和标记,以便稍后附加到我的应用程序中。
我已按照Git describe npm page 中提供的说明进行操作。该脚本运行良好,但标记信息在此处检索为空。我还在本地和远程 git 中添加了一些标签。
我可以使用git tag -l检索所有标签信息
下面是我尝试运行的脚本。
const {gitDescribe, gitDescribeSync} = require('git-describe');
// Another example: working directory, use 16 character commit hash abbreviation
const gitInfo = gitDescribeSync({
customArguments: ['--abbrev=16']
});
// Asynchronous with promise
gitDescribe(__dirname)
.then((gitInfo) => console.dir(gitInfo))
.catch((err) => console.error(err));
// Asynchronous with node-style callback
gitDescribe(__dirname, (err, gitInfo) => {
if (err)
return console.error(err);
console.dir(gitInfo);
});
节点版本.js
输出是:
{
dirty: true,
raw: 'f8f7e57e-dirty',
hash: 'f8f7e57e',
distance: null,
tag: null,
semver: null,
suffix: 'f8f7e57e-dirty',
semverString: null,
toString: [Function]
}
这里的标签信息带有空值。但是哈希字符串是正确的。 (Git 日志输出)。
commit **f8f7e57e**713b71b0f9d3181c0d19ffd (HEAD -> PF223095_US1834348_ui_gitcommit, tag: r9.0.6, origin/PF223095_US1834348_ui_gitcommit, mastere)
【问题讨论】:
标签: node.js git npm git-describe