Skip to content

Commit

Permalink
Fix crash on ratchet-from not being specified
Browse files Browse the repository at this point in the history
  • Loading branch information
slarse committed May 3, 2021
1 parent 3471295 commit 87c33bf
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function download(url: string, dst: PathLike): Promise<void> {
export async function runSorald(
source: PathLike,
soraldJarUrl: string,
ratchetFrom?: string
ratchetFrom: string
): Promise<string[]> {
const jarDstPath = 'sorald.jar';
const repo = new git.Repo(source);
Expand All @@ -44,14 +44,13 @@ export async function runSorald(
'stats.json'
);

const changedLines =
ratchetFrom === undefined
? undefined
: await (async () => {
const diff = await repo.diff(ratchetFrom);
const worktreeRoot = await repo.getWorktreeRoot();
return git.parseChangedLines(diff, worktreeRoot);
})();
const changedLines = ratchetFrom
? undefined
: await (async () => {
const diff = await repo.diff(ratchetFrom);
const worktreeRoot = await repo.getWorktreeRoot();
return git.parseChangedLines(diff, worktreeRoot);
})();

let allRepairs: string[] = [];
if (keyToSpecs.size > 0) {
Expand Down Expand Up @@ -108,7 +107,7 @@ async function run(): Promise<void> {
try {
const source: PathLike = core.getInput('source');
const soraldJarUrl: string = core.getInput('sorald-jar-url');
const ratchetFrom: string | undefined = core.getInput('ratchet-from');
const ratchetFrom: string = core.getInput('ratchet-from');
const repairedViolations: string[] = await runSorald(
source,
soraldJarUrl,
Expand Down

0 comments on commit 87c33bf

Please sign in to comment.