UNPKG

1.02 kBJavaScriptView Raw
1const commits = require('./commits')
2const numstat = require('./commit-numstat')
3const la = require('lazy-ass')
4const is = require('check-more-types')
5const R = require('ramda')
6const debug = require('debug')('ggit')
7
8const ids = R.map(R.prop('id'))
9const stats = R.map(numstat)
10const wait = list => Promise.all(list)
11const changes = R.map(R.prop('changes'))
12const justFiles = R.compose(R.uniq, R.flatten, R.map(R.keys))
13
14// returns list of unique changed file after the given commit
15function changedFilesAfter (sha, branch = 'master') {
16 la(is.unemptyString(sha), 'missing from SHA', sha)
17 debug('changed files after %s', sha)
18 debug('on branch %s', branch)
19 return commits
20 .after(sha, branch)
21 .then(ids)
22 .then(
23 R.tap(list => {
24 debug('commits')
25 debug(list)
26 })
27 )
28 .then(stats)
29 .then(wait)
30 .then(changes)
31 .then(justFiles)
32}
33
34if (!module.parent) {
35 changedFilesAfter('a12f55f').then(console.log).catch(console.error)
36}
37
38module.exports = changedFilesAfter