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

remote-git-tags

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remote-git-tags - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

license

41

index.js

@@ -1,25 +0,26 @@

var url = require('url');
var net = require('net')
var gitclient = require('git-fetch-pack');
var transport = require('git-transport-protocol');
'use strict';
const url = require('url');
const net = require('net');
const gitclient = require('git-fetch-pack');
const transport = require('git-transport-protocol');
module.exports = function (str, cb) {
// fix schemeless urls
str = str.replace(/^(?!(?:https|git):\/\/)/, 'https://');
module.exports = input => new Promise((resolve, reject) => {
// Fix schemeless urls
input = input.replace(/^(?!(?:https|git):\/\/)/, 'https://');
var tcp = net.connect({
host: url.parse(str).host,
const tcp = net.connect({
host: url.parse(input).host,
port: 9418
});
var client = gitclient(str);
var tags = {};
const client = gitclient(input);
const tags = new Map();
client.refs.on('data', function (ref) {
var name = ref.name;
client.refs.on('data', ref => {
const name = ref.name;
if (/^refs\/tags/.test(name)) {
// strip off the indicator of dereferenced tags so we can
// Strip off the indicator of dereferenced tags so we can
// override the previous entry which points at the tag hash
// and not the commit hash
tags[name.split('/')[2].replace(/\^\{\}$/, '')] = ref.hash;
tags.set(name.split('/')[2].replace(/\^\{\}$/, ''), ref.hash);
}

@@ -30,8 +31,8 @@ });

.pipe(transport(tcp))
.on('error', cb)
.on('error', reject)
.pipe(client)
.on('error', cb)
.once('end', function () {
cb(null, tags);
.on('error', reject)
.once('end', () => {
resolve(tags);
});
};
});
{
"name": "remote-git-tags",
"version": "1.0.0",
"description": "Get tags from a remote git repo. Using only JS. No git binary required.",
"version": "2.0.0",
"description": "Get tags from a remote Git repo. Using only JS. No Git binary required.",
"license": "MIT",

@@ -10,9 +10,9 @@ "repository": "sindresorhus/remote-git-tags",

"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "node test.js"
"test": "xo && ava"
},

@@ -29,2 +29,3 @@ "files": [

"repository",
"vanilla",
"js",

@@ -42,4 +43,5 @@ "javascript",

"devDependencies": {
"ava": "0.0.4"
"ava": "*",
"xo": "*"
}
}

@@ -5,7 +5,7 @@ # remote-git-tags [![Build Status](https://travis-ci.org/sindresorhus/remote-git-tags.svg?branch=master)](https://travis-ci.org/sindresorhus/remote-git-tags)

Like [`git ls-remote`](http://git-scm.com/docs/git-ls-remote.html), which doesn't require cloning the repo, but this is 100% JS, meaning no dependency on the git binary.
Like [`git ls-remote`](http://git-scm.com/docs/git-ls-remote.html), which doesn't require cloning the repo, but this is 100% JavaScript, meaning no dependency on the Git binary.
Really just some minor glue to [@chrisdickinson](https://github.com/chrisdickinson) awesome [work](https://github.com/search?utf8=%E2%9C%93&q=user%3Achrisdickinson+git-) on JSifying git.
Really just some minor glue to [@chrisdickinson](https://github.com/chrisdickinson)'s awesome [work](https://github.com/search?utf8=%E2%9C%93&q=user%3Achrisdickinson+git-) on reimplementing Git in JavaScript.
You probably shouldn't use this in production.
I'm using this successfully against GitHub repos, but the underlaying modules are not that actively maintained, so I wouldn't recommend using this for production critical code.

@@ -15,3 +15,3 @@

```sh
```
$ npm install --save remote-git-tags

@@ -24,7 +24,7 @@ ```

```js
var remoteGitTags = require('remote-git-tags');
const remoteGitTags = require('remote-git-tags');
remoteGitTags('github.com/sindresorhus/remote-git-tags', function (err, tags) {
remoteGitTags('github.com/sindresorhus/remote-git-tags').then(tags => {
console.log(tags);
//=> { 'v1.0.0': '69e308412e2a5cffa692951f0274091ef23e0e32' }
//=> Map {'v1.0.0' => '69e308412e2a5cffa692951f0274091ef23e0e32'}
});

@@ -36,22 +36,15 @@ ```

### remoteGitTags(url, callback)
### remoteGitTags(url)
Returns a `Promise<Map>` with the Git tags as keys and their commit SHA as values.
#### url
*Required*
Type: `string`
The git repo url.
Git repo URL.
#### callback(err, tags)
##### tags
Type: `object`
Tags as keys and their commit SHA as values.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
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