-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (33 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* @flow */
/*::
import type { GetDiffPoint, GetDiffPointParams, DiffPoint } from "./git";
export type CreateGetDiffPointParams = {
customGetDiffPoint?: GetDiffPoint,
getDiffPoint: GetDiffPoint
}
*/
const git = require("./git");
function createGetDiffPoint(
{ customGetDiffPoint, getDiffPoint } /*: CreateGetDiffPointParams */
) {
return customGetDiffPoint
? function(params /*: GetDiffPointParams */) /*: DiffPoint */ {
// $FlowFixMe
return customGetDiffPoint(Object.assign(params, { getDiffPoint }));
}
: getDiffPoint;
}
async function getChanged({
mainBranch = "master",
customGetDiffPoint
} /*: { mainBranch: string, customGetDiffPoint?: GetDiffPoint } */ = {}) {
const provider = git;
const getDiffPoint = createGetDiffPoint({
customGetDiffPoint,
getDiffPoint: provider.getDiffPoint
});
const currentBranch = await provider.getCurrentBranch();
const diffPoint = await getDiffPoint({ mainBranch, currentBranch });
return await provider.getChangedFiles({ diffPoint });
}
module.exports = getChanged;