Skip to content

Commit

Permalink
Get git details
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Jan 21, 2018
1 parent bea342a commit 6ad8fe9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
21 changes: 20 additions & 1 deletion source/platforms/git/localGetDiff.ts
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
export const localGetDiff = () => ""
import * as debug from "debug"
import { exec } from "child_process"

const d = debug("danger:localGetDiff")

export const localGetDiff = (base: string, head: string) =>
new Promise(done => {
const call = `git diff --no-index ${base} ${head}`
d(call)

exec(call, (err, stdout, _stderr) => {
if (err) {
console.error(`Could not get diff from git between ${base} and ${head}`)
console.error(err)
return
}

done(stdout)
})
})
21 changes: 20 additions & 1 deletion source/platforms/git/localGetFileAtSHA.ts
Original file line number Diff line number Diff line change
@@ -1 +1,20 @@
export const localGetFileAtSHA = () => ""
import * as debug from "debug"
import { exec } from "child_process"

const d = debug("danger:localGetFileAtSHA")

export const localGetFileAtSHA = (path: string, _repo: string | undefined, sha: string) =>
new Promise(done => {
const call = `git show ${sha}:"${path}"`
d(call)

exec(call, (err, stdout, _stderr) => {
if (err) {
console.error(`Could not get the file ${path} from git at ${sha}`)
console.error(err)
return
}

done(stdout)
})
})

0 comments on commit 6ad8fe9

Please sign in to comment.