I am trying Git-Describe npm package to retrieve hash information and tag to append to my application later.
I have following the instruction that are provided in the Git describe npm page. The script worked well but the tag information is retrieved as null here. Also I have added few tags in the local and my remote git.
I am able to retrieve all the tag information using git tag -l
The below is the script that I was trying to run.
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);
});
node version.js
Output is:
{
dirty: true,
raw: 'f8f7e57e-dirty',
hash: 'f8f7e57e',
distance: null,
tag: null,
semver: null,
suffix: 'f8f7e57e-dirty',
semverString: null,
toString: [Function]
}
Here the tag info are coming with null. But the hash string is correct. (Git log output).
commit **f8f7e57e**713b71b0f9d3181c0d19ffd (HEAD -> PF223095_US1834348_ui_gitcommit, tag: r9.0.6, origin/PF223095_US1834348_ui_gitcommit, mastere)