mirror of
https://github.com/elastic/kibana.git
synced 2025-04-20 16:03:20 -04:00
* [eslint] update eslint config to 0.3.0 * [eslint] autofix * [fixtures/hits] reformat to comply with max-len lint rule * [eslint] enable no-var and autofix * [eslint] enable prefer-const and autofix * [eslint] fix autofix-incompatible no-var and prefer-const violations * [eslint] enable quotes+no-extra-semi and autofix
41 lines
930 B
JavaScript
41 lines
930 B
JavaScript
import SimpleGit from 'simple-git';
|
|
import { promisify } from 'bluebird';
|
|
import { includes } from 'lodash';
|
|
|
|
export default function filesToCommit(path) {
|
|
const simpleGit = new SimpleGit(path);
|
|
const gitDiff = promisify(simpleGit.diff, simpleGit);
|
|
|
|
return gitDiff(['--name-status', '--cached'])
|
|
.then(output => {
|
|
return output
|
|
.split('\n')
|
|
.map(line => line.trim().split('\t'))
|
|
.filter(parts => parts.length === 2)
|
|
.map(parts => {
|
|
const status = parts.shift();
|
|
const name = parts.join('\t').trim();
|
|
return { status, name };
|
|
});
|
|
});
|
|
}
|
|
|
|
export function getFilename(file) {
|
|
return file.name;
|
|
}
|
|
|
|
export function isAdded(file) {
|
|
return file.status === 'A';
|
|
}
|
|
|
|
export function isDeleted(file) {
|
|
return file.status === 'D';
|
|
}
|
|
|
|
export function isUnmerged(file) {
|
|
return file.status === 'U';
|
|
}
|
|
|
|
export function isStaged(file) {
|
|
return !isDeleted(file) && !isUnmerged(file);
|
|
}
|