Skip to content

Commit 6b4c01c

Browse files
committed
fix(vcs): fix handling of promises in VSC provider
1 parent 86c3ae1 commit 6b4c01c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/vcs-provider.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export async function gitsvnRevision(file: string, workspace: string): Promise<n
5454
exec(`git svn info ${file}`, { cwd: workspace }, (error, stdout: string, stderr: string) => {
5555
if (error) {
5656
reject(`Could not retrieve SVN revision for file: ${file}. Error(s): ${stderr}`);
57+
return;
5758
}
5859

5960
const revRegex = /^Last Changed Rev: (\d+)\s*$/gm;
@@ -63,11 +64,14 @@ export async function gitsvnRevision(file: string, workspace: string): Promise<n
6364
const maybeRevision = Number(matches[0][1]);
6465
if (isNaN(maybeRevision)) {
6566
reject(`Unexpected command output: ${matches[0][1]}`);
67+
} else {
68+
resolve(maybeRevision);
6669
}
67-
resolve(maybeRevision);
70+
} else {
71+
reject('Could not derive SVN revision from git-svn history.');
6872
}
6973

70-
reject('Could not derive SVN revision from git-svn history.');
74+
return;
7175
});
7276
});
7377
}
@@ -95,15 +99,13 @@ export async function revision(file: string, workspace: string): Promise<string>
9599
}
96100

97101
case VcsKind.svn: {
98-
return new Promise<string>((resolve, reject) => {
99-
svnRevision(file, workspace).then((revision: number) => resolve(`${revision}`));
100-
});
102+
let revision = await svnRevision(file, workspace);
103+
return `${revision}`;
101104
}
102105

103106
case VcsKind.gitsvn: {
104-
return new Promise<string>((resolve, reject) => {
105-
gitsvnRevision(file, workspace).then((revision: number) => resolve(`${revision}`));
106-
});
107+
let revision = await gitsvnRevision(file, workspace);
108+
return `${revision}`;
107109
}
108110

109111
default:

0 commit comments

Comments
 (0)