Skip to content

Commit

Permalink
Add uncommited changeds to LocalGit
Browse files Browse the repository at this point in the history
  * details in #972
  • Loading branch information
Soyn committed Feb 17, 2020
1 parent 7d76e4b commit e86579c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion source/platforms/LocalGit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ export class LocalGit implements Platform {
const base = this.options.base || "master"
const head = "HEAD"
const diff = await this.getGitDiff()
const unstagedDiff = await localGetDiff(base, head, false)
const commits: GitCommit[] = await localGetCommits(base, head)
const gitJSON = diffToGitJSONDSL(diff, commits)
const gitJSON = diffToGitJSONDSL(diff.concat(unstagedDiff), commits)

const config: GitJSONToGitDSLConfig = {
repo: process.cwd(),
Expand Down
7 changes: 4 additions & 3 deletions source/platforms/git/localGetDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { debug } from "../../debug"
import { spawn } from "child_process"

const d = debug("localGetDiff")

export const localGetDiff = (base: string, head: string) =>
const stagedDiffArgs = (base: string, head: string) => ["diff", `${base}...${head}`]
const unstagedDiffArgas = (base: string) => ["diff", base]
export const localGetDiff = (base: string, head: string, onlyUsedStaged: boolean = true) =>
new Promise<string>(done => {
const args = ["diff", `${base}...${head}`]
const args = onlyUsedStaged ? stagedDiffArgs(base, head) : unstagedDiffArgas(base)
let stdout = ""

const child = spawn("git", args, { env: process.env })
Expand Down

0 comments on commit e86579c

Please sign in to comment.