
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
get-git-version
Advanced tools
Gets Git version and commit information for one or more repositories.
Gets Git version and commit information for one or more repositories. This is useful for applications that span multiple repositories or use submodules.
Git is expected to be preinstalled (and in PATH
).
The script simply runs shell commands similar to:
git config --get remote.origin.url
git rev-parse --abbrev-ref HEAD
git rev-parse HEAD
git --no-pager log --pretty=format:"%at" -n1
git diff-index --quiet HEAD --
git describe --tags --match "v[0-9]*" HEAD
npm install -g get-git-version
To get information about the current directory, run:
get-git-version
If the working directory contains a package.json
file, it will be used to set the name
and default version
.
Otherwise, the name of the current folder is used as the name
and version
is not set.
{
"name": "get-git-version",
"version": "0.0.4",
"git": {
"repository": "https://github.com/polys/git-version.git",
"branch": "master",
"sha1": "dccb48950fa60511c3b235404209f17610aab67e",
"date": "2018-04-21T17:31:35+01:00",
"clean": false
},
"components": []
}
or with --version-only
:
{
"name": "get-git-version",
"version": "0.1.4"
}
-w [path]
or --working-dir [path]
overrides the working directory (defaults to the current directory)-o [path]
or --out-file [path]
writes the output to a file instead of stdout
-c [path]
or --config-file [path]
overrides the config file name (defaults to .git-version.config.json
)--app-id [id]
overrides the application id
(defaults to app
)--version-tag-prefix [prefix]
overrides the default version tag prefix (defaults to v[0-9]*
)--no-pretty
disables pretty printing the output JSON--version-only
returns only the version, without git information-h
or --help
outputs usage informationCreate a .git-version.config.json
file with a simple array, similar to:
[
{
"id": "app",
"name": "Test App",
"path": ".",
"versionTagPrefix": "v[0-9]*",
"version": "0.1"
},
{
"id": "dummy",
"name": "Dummy Component",
"path": ".",
"versionTagPrefix": "v[0-9]*"
}
]
All entries are expected to have an id
.
If name
is specified, it's simply copied to the output.
If path
is specified, it's joined to the working directory path; otherwise, defaults to the working directory.
An item whose id
is app
(can be overridden using the --app-id
command-line option) is required and treated as the main application. All other items are considered components of that application.
If versionTagPrefix
is specified, a version
is computed for the component, based on the most recent git tag that starts with this prefix. If no matching tag is not found, version
won't be defined.
FAQs
Gets Git version and commit information for one or more repositories.
The npm package get-git-version receives a total of 153 weekly downloads. As such, get-git-version popularity was classified as not popular.
We found that get-git-version demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.