Repository: steveukx/git-js (ts)

Issue:
git.branch results missing some branch name
I found that git.branch does not result  some branch name

git branch -v -a 

![image](https://user-images.githubusercontent.com/15901380/90329255-9cce1100-dfd5-11ea-9709-dc3be76b8cd2.png)

simple branch
```js
const simpleGit = require('simple-git');
const git = simpleGit();
git.branch().then(result => {
    console.log(result) // ==> { current: '', local: [ 'dev' ], remote: [ 'dev' ] }
})
```
The reason is because my submission contains '\r \r' 

![image](https://user-images.githubusercontent.com/15901380/90329076-1c5ae080-dfd4-11ea-8031-09aa040a3b4d.png)

The Solution:

file：src/lib/parsers/parse-branch.js ( version：2.17.0 )

the RegExp (/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/) adds a multiline attribute
```js
/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/   ===> /^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/m
```
![image](https://user-images.githubusercontent.com/15901380/90329200-1f0a0580-dfd5-11ea-9e8a-0589f0f8b42b.png)
Get current branch returns empty string 
Hi, when I use `branch.current` to get the current branch name, the result is empty string sometimes.

I look into this using `DEBUG=simple-git` and found the command `git branch -v -a` it use output like this:
![image](https://user-images.githubusercontent.com/3615672/110118305-21a73d80-7df5-11eb-93fe-374d05ff2bab.png)

Whenever a `^M` in commit message, the branch info is missing,  `^M` is common to see in commit messages. (When has `\r\r`, or `\r\n`)

There is another issue about this: https://github.com/steveukx/git-js/issues/500

lib version: 2.36.0
os: window 10

Pull request:
fix: parsing `git.branch` includes carriage returns


Closes #596
Closes #500 

Patch:
diff --git a/src/lib/parsers/parse-branch.ts b/src/lib/parsers/parse-branch.ts
index 357da3d..d24cb8f 100644
--- a/src/lib/parsers/parse-branch.ts
+++ b/src/lib/parsers/parse-branch.ts
@@ -10,7 +10,7 @@ const parsers: LineParser<BranchSummaryResult>[] = [
          name, commit, label
       );
    }),
-   new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/, (result, [current, name, commit, label]) => {
+   new LineParser(/^(\*\s)?(\S+)\s+([a-z0-9]+)\s(.*)$/s, (result, [current, name, commit, label]) => {
       result.push(
          !!current,
          false,


Test patch:
diff --git a/test/unit/__fixtures__/index.ts b/test/unit/__fixtures__/index.ts
index 9d5590d..c36b08b 100644
--- a/test/unit/__fixtures__/index.ts
+++ b/test/unit/__fixtures__/index.ts
@@ -2,6 +2,7 @@
 export * from './child-processes';
 export * from './expectations';
 
+export * from './responses/branch';
 export * from './responses/commit';
 export * from './responses/diff';
 export * from './responses/merge';
diff --git a/test/unit/__fixtures__/responses/branch.ts b/test/unit/__fixtures__/responses/branch.ts
new file mode 100644
index 0000000..c2532d9
--- /dev/null
+++ b/test/unit/__fixtures__/responses/branch.ts
@@ -0,0 +1,11 @@
+
+export function branchSummary (...lines: string[]) {
+   return lines.join('\n');
+}
+
+export function branchSummaryLine(commit: string, hash = '', current = false) {
+   const prefix = current ? '*' : ' ';
+   const branch = hash || commit.replace(/[^a-z]/i, '').substr(0, 5);
+
+   return `${prefix} branch-${branch} ${hash || branch.substr(0, 5)} ${commit}`;
+}
diff --git a/test/unit/branch.spec.ts b/test/unit/branch.spec.ts
index c2e0ad4..3e3b304 100644
--- a/test/unit/branch.spec.ts
+++ b/test/unit/branch.spec.ts
@@ -1,5 +1,12 @@
 import { BranchSingleDeleteResult, BranchSummary, SimpleGit } from 'typings';
-import { assertExecutedCommands, closeWithSuccess, like, newSimpleGit } from './__fixtures__';
+import {
+   assertExecutedCommands,
+   branchSummary,
+   branchSummaryLine,
+   closeWithSuccess,
+   like,
+   newSimpleGit
+} from './__fixtures__';
 
 import { parseBranchSummary } from '../../src/lib/parsers/parse-branch';
 import { BranchSummaryResult } from '../../src/lib/responses/BranchSummary';
@@ -100,6 +107,37 @@ describe('branch', () => {
 
    describe('parsing', () => {
 
+      it('handles branches with carriage returns in the commit message', async () => {
+         expect(parseBranchSummary(branchSummary(
+            branchSummaryLine('Something', '012de2', false),
+            branchSummaryLine('Add support for carriage \r returns', '012de3', true),
+            branchSummaryLine('Something else', '012de4', false),
+         ))).toEqual(like({
+            branches: {
+               'branch-012de2': {
+                  commit: '012de2',
+                  current: false,
+                  label: 'Something',
+                  name: 'branch-012de2',
+               },
+               'branch-012de3': {
+                  commit: '012de3',
+                  current: true,
+                  label: 'Add support for carriage \r returns',
+                  name: 'branch-012de3',
+               },
+               'branch-012de4': {
+                  commit: '012de4',
+                  current: false,
+                  label: 'Something else',
+                  name: 'branch-012de4',
+               },
+            }
+         }))
+      });
+
+
+
       it('branch detail by name', async () => {
          const actual = parseBranchSummary(`
   cflynn07-add-git-ignore            a0b67a3 Add support for filenames containing spaces