in github/changed-files/git-changed-files/src/fetchGitStatus.js [62:117]
function fetchGitStatus(options) {
return new Promise((resolve, reject) => {
let {
baseBranch,
diffFilter,
formats,
showStatus,
showCommitted,
showUnCommitted,
head,
} = options;
if (!(showCommitted || showUnCommitted)) {
return reject(chalk.keyword('orange')('Either showCommitted or showUnCommitted must be true.'));
}
let statusCmd = showStatus ? '--name-status' : '--name-only';
let baseCmd = `git diff --relative ${statusCmd} --diff-filter=${diffFilter}`;
let commitedCmd = baseCmd.concat(` ${baseBranch}...${head}`);
let stagedCmd = baseCmd.concat(' --staged');
let committedFiles, stagedFiles, unStagedFiles;
let fileList = {};
process.on('onError', (error) => {
reject(chalk.red(error));
});
try {
if (showCommitted) {
committedFiles = findFiles(commitedCmd, formats, showStatus);
fileList.committedFiles = committedFiles;
}
if (showUnCommitted) {
stagedFiles = findFiles(stagedCmd, formats, showStatus);
unStagedFiles = findFiles(baseCmd, formats, showStatus);
fileList.unCommittedFiles = removeDuplicateEntries(stagedFiles, unStagedFiles);
}
resolve(fileList);
} catch(err) {
reject(chalk.red(err));
}
});
}