Skip to content

Commit

Permalink
fix(vcs): fix handling of promises in VSC provider
Browse files Browse the repository at this point in the history
  • Loading branch information
croesnick committed Feb 19, 2022
1 parent 7d54025 commit d93262a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/vcs-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function gitsvnRevision(file: string, workspace: string): Promise<n
exec(`git svn info ${file}`, { cwd: workspace }, (error, stdout: string, stderr: string) => {
if (error) {
reject(`Could not retrieve SVN revision for file: ${file}. Error(s): ${stderr}`);
return;
}

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

reject('Could not derive SVN revision from git-svn history.');
return;
});
});
}
Expand Down Expand Up @@ -95,15 +99,13 @@ export async function revision(file: string, workspace: string): Promise<string>
}

case VcsKind.svn: {
return new Promise<string>((resolve, reject) => {
svnRevision(file, workspace).then((revision: number) => resolve(`${revision}`));
});
let revision = await svnRevision(file, workspace);
return `${revision}`;
}

case VcsKind.gitsvn: {
return new Promise<string>((resolve, reject) => {
gitsvnRevision(file, workspace).then((revision: number) => resolve(`${revision}`));
});
let revision = await gitsvnRevision(file, workspace);
return `${revision}`;
}

default:
Expand Down

0 comments on commit d93262a

Please sign in to comment.