You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github-api-tags-full

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-api-tags-full

Gets all tags with their respective commit for sorting from Github API

7.1.0
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

github-api-tags-full

Gets all tags with their respective commit for sorting from Github API

david

NPM

API

Note that this module has to make one Github API call per tag in order to retrieve the commit details.

You may want to authenticate to Github as user first (see github authentication) for higher API rate limits.

Usage

npm install github-api-tags-full github

This module uses the github module for accessing the Github API:

var GitHubApi     = require('github'),
    GithubApiTags = require('github-api-tags-full');

var github = new GitHubApi({
  version: '3.0.0'
});

var gat = new GithubApiTags();
gat.fetch({ user: 'golang', repo: 'go' }, github)
.then(function(tags) {
  console.log(tags);
});

The resulting list of tags with commit can then be used to sort, e.g. by date:

npm install github-api-tags-full github moment
var GitHubApi     = require('github'),
    GithubApiTags = require('github-api-tags-full'),
    moment        = require('moment');

var github = new GitHubApi({
  version: '3.0.0'
});

var gat = new GithubApiTags();
gat.fetch({ user: 'golang', repo: 'go' }, github)
.then(function(tags) {
  var tagsSorted = tags.sort(byAuthorDateAsc).reverse(); // descending
  console.log(tagsSorted);
});

var byAuthorDateAsc = function(tagA, tagB) {
  return githubCompareDates(
    tagA.commit.author.date,
    tagB.commit.author.date
  );
};
var githubCompareDates = function(dateStrA, dateStrB) {
  return moment(dateStrA).diff(dateStrB);
};

A more comprehensive example with progress indicator and http replay can be found in example.js.

Keywords

github

FAQs

Package last updated on 13 Oct 2016

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