Skip to content

Commit 205e1ea

Browse files
committed
pass staging argument, to use when creating diff
1 parent 1e7ee10 commit 205e1ea

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

source/platforms/LocalGit.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class LocalGit implements Platform {
5050

5151
const config: GitJSONToGitDSLConfig = {
5252
repo: process.cwd(),
53+
staging: this.options.staging,
5354
baseSHA: this.options.base || "master",
5455
headSHA: "HEAD",
5556
getFileContents: localGetFileAtSHA,

source/platforms/git/gitJSONToGitDSL.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export interface GitJSONToGitDSLConfig {
2525
/** This is used in getFileContents to figure out your repo */
2626
repo?: string
2727

28-
// These two will be tricky when trying to do this for staged files
28+
/** Whether to diff only files from the staging area */
29+
staging: boolean = false
2930

3031
/** The sha things are going into */
3132
baseSHA: string
@@ -48,7 +49,7 @@ export const gitJSONToGitDSL = (gitJSONRep: GitJSONDSL, config: GitJSONToGitDSLC
4849
? null
4950
: memoize(
5051
(base: string, head: string) => {
51-
return config.getFullDiff!(base, head)
52+
return config.getFullDiff!(base, head, config.staging)
5253
},
5354
(base: string, head: string) => `${base}...${head}`
5455
)
@@ -194,7 +195,7 @@ export const gitJSONToGitDSL = (gitJSONRep: GitJSONDSL, config: GitJSONToGitDSLC
194195
if (config.getStructuredDiffForFile) {
195196
fileDiffs = await config.getStructuredDiffForFile(config.baseSHA, config.headSHA, filename)
196197
} else {
197-
const diff = await getFullDiff!(config.baseSHA, config.headSHA)
198+
const diff = await getFullDiff!(config.baseSHA, config.headSHA, config.staging)
198199
fileDiffs = parseDiff(diff)
199200
}
200201
const structuredDiff = fileDiffs.find(diff => diff.from === filename || diff.to === filename)

0 commit comments

Comments
 (0)