Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commit-hash

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commit-hash

Get commit hash from a branch name, tag, or reference

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

commit-hash

Obtain a repository's commit hash from a branch name, tag, or reference.

Installation

npm install commit-hash

Usage

var commitHash = require('commit-hash');

// looking up a short commit hash, in a project in the current directory
commitHash('21f6b', function(err, hash) {
     console.log(hash); // => '21f6ba4e644e77d6e20eaa5156a928b6d75fdf76'
});

// looking up a tag with modifiers, in a project somewhere else
commitHash('v0.1.0^^', {dir: '/home/dgo/repos/commit-hash'}, function(err, hash) {
    console.log(hash); // => '285d19c23a56662bab97c75b4bfc80a175dfdae2'
});

// looking up a remote branch, after fetching from all remotes
// to ensure the local repo has updated references
commitHash('origin/tests-unused-branch', {
    dir: '/home/dgo/repos/commit-hash',
    fetch: true
}, function(err, hash) {
    console.log(hash); // => '3f07195438a6a846554ed4b8cd7b3223a8c5e91e'
});

License

MIT license - http://www.opensource.org/licenses/mit-license.php

Keywords

FAQs

Package last updated on 05 Nov 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc