<commit_before>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
```shell
npm install git-show-branch-parser
```

### Require
```js
var showBranchParser = require('git-show-branch-parser');
```

### Parse!
```js
showBranchParser('path/to/show-branch/output.txt', function (err, obj) {
    console.log(JSON.strinify(obj, null, 4));
});
```
### Or use promises:
This function returns an RSVP promise.
```js
var sbpPromise = showBranchParser('path/to/show-branch/output.txt');
sbpPromise.then(function (obj) {
    console.log(JSON.strinify(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:
```js
var showBranchParser = require('git-show-branch-parser');
showBranchParser('path/to/show-branch/output.txt', function (err, obj) {
    console.log(JSON.strinify(obj, null, 4));
});
```

The above code will print the following:

```json
{
    "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"<commit_msg>fixed typo in readme<commit_after>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
```shell
npm install git-show-branch-parser
```

### Require
```js
var showBranchParser = require('git-show-branch-parser');
```

### Parse!
```js
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.
```js
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:
```js
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:

```json
{
    "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"
{'fraction_non_alphanumeric': 0.10913705583756345, 'fraction_numerical': 0.00692201199815413, 'mean_word_length': 3.0814500941619585, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '273009', 'n_tokens_mistral': 2460, 'n_tokens_neox': 2355, 'n_words': 984}