Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// not async for test
const clonePromise = git.clone({
dir: projectRoot,
url: cloneDest,
ref: "master",
emitter,
...options
})
while (true) {
await delay(1000)
try {
const list = await git.listFiles({ dir: projectRoot })
const e = await git.status({ dir: projectRoot, filepath: list[0] })
console.log("status correct with", e)
break
} catch (e) {
console.log("wait...", e.message)
}
}
await clonePromise
return clonePromise
}
static async isIgnored(dir, filepath, homedir = os.homedir()) {
if (!(await fse.pathExists(path.resolve(dir, filepath)))) {
return true;
}
if (!(await fse.pathExists(path.resolve(dir, '.git')))) {
return true;
}
const status = await git.status({ dir, filepath });
if (status === 'ignored') {
return true;
}
// need to re-check the modified against the globally ignored
// see: https://github.com/isomorphic-git/isomorphic-git/issues/444
const globalConfig = path.resolve(homedir, '.gitconfig');
const config = ini.parse(await fse.readFile(globalConfig, 'utf-8'));
const globalIgnore = path.resolve(homedir, (config.core && config.core.excludesfile) || '.gitignore_global');
if (await fse.pathExists(globalIgnore)) {
const ign = ignore().add(await fse.readFile(globalIgnore, 'utf-8'));
return ign.ignores(filepath);
}
return false;
}
export async function getGitStatusInRepository(
projectRoot: string,
relpath: string
): Promise {
try {
const status = await git.status({ fs, dir: projectRoot, filepath: relpath })
return status
} catch (e) {
return "untracked"
}
}
export async function getFileStatus(
projectRoot: string,
relpath: string,
ref: string | null = null
): Promise {
try {
return await git.status({ dir: projectRoot, filepath: relpath, ref })
} catch (e) {
return "__error__"
}
}
if( buffer.type == "directory" ){
let action = {
type:"button",
label:"git",
text:"Stage All",
cb:gitAdd.bind(null, buffer)
};
APP.async(_=>{
APP.setBufferAction( buffer, action );
});
return;
}
git.status({dir, filepath:relative})
.then(result=>{
let action = Object.assign({label:"git"}, statusMap[result]);
if( action.cb )
action.cb = action.cb.bind(null, buffer);
APP.setBufferAction( buffer, action );
APP.setBufferColor( buffer, colorMap[result] );
}).catch(ex=>{
APP.error(relative);
log(ex);
});
}