<commit_before># branch-name [![Build status for branch-name on Circle CI.](https://img.shields.io/circleci/project/sholladay/branch-name/master.svg "Circle Build Status")](https://circleci.com/gh/sholladay/branch-name "Branch Name Builds")

> Get the current branch name.

## Why?

 - Clean, minimal, promise-based API.
 - Respects your `$PATH`.
 - Uses the most reliable branch [detection algorithm](http://stackoverflow.com/a/19585361/2990144).
 - Gives you control in weird situations.

## Install

```sh
npm install branch-name --save
```

## Usage

Get it into your program.

```js
const branchName = require('branch-name');
```

Get the current branch name.

```js
branchName.get().then((name) => {
   console.log(name);
});
```

Get the current branch name, but with a fallback result for detached head and non-repository situations.

```js
branchName.assume('dev').then((name) => {
   console.log(name);  // prints current branch if possible, 'dev' otherwise
});
```

Get the current branch name, with the default `master` as a fallback.

```js
branchName.assumeMaster().then((name) => {
   console.log(name);  // prints current branch if possible, 'master' otherwise
});
```

## Contributing

See our [contributing guidelines](https://github.com/sholladay/branch-name/blob/master/CONTRIBUTING.md "The guidelines for participating in this project.") for more details.

1. [Fork it](https://github.com/sholladay/branch-name/fork).
2. Make a feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. [Submit a pull request](https://github.com/sholladay/branch-name/compare "Submit code to this project for review.").

## License

[MPL-2.0](https://github.com/sholladay/branch-name/blob/master/LICENSE "The license for branch-name.") © [<NAME>](http://seth-holladay.com "Author of branch-name.")

Go make something, dang it.
<commit_msg>Add API documentation and Related section.<commit_after># branch-name [![Build status for branch-name on Circle CI.](https://img.shields.io/circleci/project/sholladay/branch-name/master.svg "Circle Build Status")](https://circleci.com/gh/sholladay/branch-name "Branch Name Builds")

> Get the current branch name.

## Why?

 - Clean, minimal, promise-based API.
 - Respects your `$PATH`.
 - Uses the most reliable branch [detection algorithm](http://stackoverflow.com/a/19585361/2990144).
 - Gives you control in weird situations.

## Install

```sh
npm install branch-name --save
```

## Usage

Get it into your program.

```js
const branchName = require('branch-name');
```

Get the current branch name.

```js
branchName.get().then((name) => {
   console.log(name);
});
```

Get the current branch name, but with a fallback result for detached head and non-repository situations.

```js
branchName.assume('dev').then((name) => {
   console.log(name);  // prints current branch if possible, 'dev' otherwise
});
```

Get the current branch name, with the default `master` as a fallback.

```js
branchName.assumeMaster().then((name) => {
   console.log(name);  // prints current branch if possible, 'master' otherwise
});
```

## API

### .get(option)

#### option

Type: `object`

##### cwd

Type: `string`<br>
Default: `process.cwd()`

The directory who's branch you want to return.

### .assume(name, option)

Same options as `.get()`, but will return `name` if not in a git repository or the HEAD is detached.

### .assumeMaster(option)

Same options as `.assume()` but always uses "master" as the fallback name.

## Related

 - [head-hash](https://github.com/sholladay/head-hash) - Get the current commit hash.

## Contributing

See our [contributing guidelines](https://github.com/sholladay/branch-name/blob/master/CONTRIBUTING.md "The guidelines for participating in this project.") for more details.

1. [Fork it](https://github.com/sholladay/branch-name/fork).
2. Make a feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. [Submit a pull request](https://github.com/sholladay/branch-name/compare "Submit code to this project for review.").

## License

[MPL-2.0](https://github.com/sholladay/branch-name/blob/master/LICENSE "The license for branch-name.") © [<NAME>](http://seth-holladay.com "Author of branch-name.")

Go make something, dang it.

{'fraction_non_alphanumeric': 0.15299435028248587, 'fraction_numerical': 0.009943502824858758, 'mean_word_length': 4.2440758293838865, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, 'https://': 13, 'lorem ipsum': 0, 'www.': 0, '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': '4680704', 'n_tokens_mistral': 1456, 'n_tokens_neox': 1369, 'n_words': 438}