提交 6828ae1a 编写于 作者: E Eric Amodio

Removes trim & fixes regex

上级 c45eac1a
......@@ -1915,18 +1915,18 @@ export class Repository {
const fn = (line: string): Ref | null => {
let match: RegExpExecArray | null;
if (match = /^refs\/heads\/([^ ]+) ([0-9a-f]{40}) ?([0-9a-f]{40})?$/.exec(line)) {
if (match = /^refs\/heads\/([^ ]+) ([0-9a-f]{40}) ([0-9a-f]{40})?$/.exec(line)) {
return { name: match[1], commit: match[2], type: RefType.Head };
} else if (match = /^refs\/remotes\/([^/]+)\/([^ ]+) ?([0-9a-f]{40}) ([0-9a-f]{40})?$/.exec(line)) {
} else if (match = /^refs\/remotes\/([^/]+)\/([^ ]+) ([0-9a-f]{40}) ([0-9a-f]{40})?$/.exec(line)) {
return { name: `${match[1]}/${match[2]}`, commit: match[3], type: RefType.RemoteHead, remote: match[1] };
} else if (match = /^refs\/tags\/([^ ]+) ([0-9a-f]{40}) ?([0-9a-f]{40})?$/.exec(line)) {
} else if (match = /^refs\/tags\/([^ ]+) ([0-9a-f]{40}) ([0-9a-f]{40})?$/.exec(line)) {
return { name: match[1], commit: match[3] ?? match[2], type: RefType.Tag };
}
return null;
};
return result.stdout.trim().split('\n')
return result.stdout.split('\n')
.filter(line => !!line)
.map(fn)
.filter(ref => !!ref) as Ref[];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册