finos / finos/git-proxy

Refactor `getDiff` to store the diff into the action

Open
#1,693 2 comments 0 reactions 1 assignee Claimed by @amnkarn View on GitHub
good first issue
Dominant language
TypeScript
Stars
249
Forks
176
Avg merge
3d 8h
Merged PRs (30d)
20

Description

**Is your feature request related to a problem? Please describe.**

Right now, `getDiff` stores the diff as content in a step via `step.setContent`, making the diff harder to fetch from plugins (as of the plugin revamp #1683) and subsequent actions like `scanDiff`:

```ts
...
step.log(`Executing "git diff ${commitFrom} ${action.commitTo}" in ${path}`);
const revisionRange = `${commitFrom}..${action.commitTo}`;
const diff = await git.diff([revisionRange]);
step.log(diff);
step.setContent(diff);
} catch (error: unknown) {
const msg = getErrorMessage(error);
step.setError(msg);
} finally {
action.addStep(step);
}
return action;
```

**Describe the solution you'd like**
Refactor `getDiff` so that adding the diff as content isn't necessary. We might need to look into *why* it was done this way in the first place. If we need to keep it as step content, we can just store the diff regardless via `action.diff = diff`, and then refactor any usages to use that instead.

**Additional context**
Related plugin revamp: #1683

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.