What is git-repo-info?
The git-repo-info npm package provides a simple way to gather information about a Git repository. It can be used to retrieve details such as the current branch, the latest commit hash, and other repository metadata.
What are git-repo-info's main functionalities?
Get Current Branch
This feature allows you to get the current branch name of the Git repository.
const gitRepoInfo = require('git-repo-info');
const info = gitRepoInfo();
console.log(info.branch);
Get Latest Commit Hash
This feature allows you to get the latest commit hash of the Git repository.
const gitRepoInfo = require('git-repo-info');
const info = gitRepoInfo();
console.log(info.sha);
Get Repository Root
This feature allows you to get the root directory of the Git repository.
const gitRepoInfo = require('git-repo-info');
const info = gitRepoInfo();
console.log(info.root);
Get Committer Date
This feature allows you to get the committer date of the latest commit in the Git repository.
const gitRepoInfo = require('git-repo-info');
const info = gitRepoInfo();
console.log(info.committerDate);
Other packages similar to git-repo-info
simple-git
simple-git is a lightweight interface for running Git commands in any node.js application. It provides a more comprehensive set of Git functionalities compared to git-repo-info, including the ability to execute various Git commands programmatically.
nodegit
nodegit is a native Node.js library that provides a high-level API for interacting with Git repositories. It offers extensive Git functionalities, including repository management, commit history, and branch operations, making it more feature-rich than git-repo-info.
isomorphic-git
isomorphic-git is a pure JavaScript implementation of Git that works in both Node.js and browser environments. It provides a wide range of Git functionalities, including cloning, committing, and pushing, making it a versatile alternative to git-repo-info.
git-repo-info
Retrieves repo information without relying on the git
command.
Usage
var getRepoInfo = require('git-repo-info');
var info = getRepoInfo();
info.branch
info.sha
info.abbreviatedSha
info.tag
info.lastTag
info.commitsSinceLastTag
info.committer
info.committerDate
info.author
info.authorDate
info.commitMessage
info.root
info.commonGitDir
info.worktreeGitDir
When called without any arguments, git-repo-info
will automatically lookup upwards
into parent directories to find the first match with a .git
folder.
If passed an argument, it will be assumed to be the path to the repo's .git
folder
to inspect.