npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-show-branch-parser

v0.1.3

Published

Parse output of `git show-branch` to a JS object

Downloads

8

Readme

gitShowBranchParser

Parse output of git show-branch command into JS object.

Show-branch prints a unique tabular format that indicates which recent are present in all of your branches. This output has been optimized for reading on the command line, and does not adapt well if you want to display this information on a web page, or use it in an application. git-show-branch-parser will parse the output into a more usable javascript object.

Usage

Install

npm install git-show-branch-parser

Require

var showBranchParser = require('git-show-branch-parser');

Parse!

showBranchParser('path/to/show-branch/output.txt', function (err, obj) {
    console.log(JSON.stringify(obj, null, 4));
});

Or use promises:

This function returns an RSVP promise.

var sbpPromise = showBranchParser('path/to/show-branch/output.txt');
sbpPromise.then(function (obj) {
    console.log(JSON.stringify(obj, null, 4));
}).catch(function (err) {
    console.assert(false, err);
});

Object Structure:

The git show-branch output is parsed into an object of the following form:

{
    branches: [
        {
            label: '...',
            latestCommit: '...'
        },
        ...
    ],
    commits: [
        {
            label: '...',
            commitMessage: '...',
            branches: // order mimics that of the branches array above
                [
                    boolean, // true if commit is in corresponding branch
                    boolean, // true if commit is in corresponding branch
                    ...
                ]
        },
        ...
    ]
}

Details

For details about how to use git show-branch, refer to the documentation: https://www.kernel.org/pub/software/scm/git/docs/git-show-branch.html

Suppose that we have three branches used in our build/release cycle: master, release, and develop. Before creating a release, it would be useful to see which commits are in develop, but not in the release branch. Similarly, before pushing the release to master, it would be useful to document which commits are going to me merged from master into release.

The command git show-branch is very useful for this. By running git show-branch origin/master, origin/release, origin/develop, we will get the following example output:

! [origin/master] update calendars on MICIS > REPORTS tab so that the sql queries will include the day specified.  This updates Billing Reports, Subject Enrollment, URSI Stats
 ! [origin/release] update asmt ref to develop from autoq
  ! [origin/develop] update asmt ref to develop from autoq
---
  + [12679ba] update asmt ref to develop from autoq
  - [36eb3f4] Merge pull request #90 from MRN-Code/auto_queue
 ++ [caf7e93] update asmt checksum.  Also, ORDER study list by study names, update wording in a message to user for readability, and remove extra onPageLoad function that was not being called, but if so, would create errors
 ++ [e5073e4] update error message function names
 ++ [cf62f75] added check for loginid on subj details
--- [fc5b144] Merge branch 'auto_queue' of github.com:MRN-Code/micis into auto_queue

The above output indicates that the first two commits are only present in origin/develop. The next three commits are present in both origin/develop, and orign/release, and the last commit is present in all three branches.

By writing the output from git show-branch, we can later parse it into a JavaScript object using this utility:

var showBranchParser = require('git-show-branch-parser');
showBranchParser('path/to/show-branch/output.txt', function (err, obj) {
    console.log(JSON.stringify(obj, null, 4));
});

The above code will print the following:

{
    "branches": [
        {
            "label": "origin/master",
            "latestCommit": "update calendars on MICIS > REPORTS tab so that the sql queries will include the day specified.  This updates Billing Reports, Subject Enrollment, URSI Stats"
        },
        {
            "label": "origin/release",
            "latestCommit": "update asmt ref to develop from autoq"
        },
        {
            "label": "origin/develop",
            "latestCommit": "update asmt ref to develop from autoq"
        }
    ],
    "commits": [
        {
            "label": "12679ba",
            "commitMessage": "update asmt ref to develop from autoq",
            "branches": [
                false,
                true,
                true
            ]
        },
        {
            "label": "36eb3f4",
            "commitMessage": "Merge pull request #90 from MRN-Code/auto_queue",
            "branches": [
                false,
                true,
                true
            ]
        },
        {
            "label": "caf7e93",
            "commitMessage": "update asmt checksum.  Also, ORDER study list by study names, update wording in a message to user for readability, and remove extra onPageLoad function that was not being called, but if so, would create errors",
            "branches": [
                false,
                true,
                true
            ]
        },
        {
            "label": "e5073e4",
            "commitMessage": "update error message function names",
            "branches": [
                false,
                true,
                true
            ]
        },
        {
            "label": "cf62f75",
            "commitMessage": "added check for loginid on subj details",
            "branches": [
                false,
                true,
                true
            ]
        },
        {
            "label": "fc5b144",
            "commitMessage": "Merge branch 'auto_queue' of github.com:MRN-Code/micis into auto_queue",
            "branches": [
                false,
                true,
                true
            ]
        }
    ]
}

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code using Grunt.

TODO

  1. Add unit testing
  2. Differentiate between merge and normal commits