Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return await using(async (ds) => {
let repo = ds(await Repository.open(targetDirname));
let commit = ds(await repo.getCommit(sha));
let opts: any = {};
// Equivalent of `git reset --hard HEAD && git clean -xdf`
d(`Found commit: ${targetDirname}:${commit.sha()}`);
opts.checkoutStrategy = Checkout.STRATEGY.FORCE |
Checkout.STRATEGY.RECREATE_MISSING |
Checkout.STRATEGY.REMOVE_UNTRACKED |
Checkout.STRATEGY.USE_THEIRS;
await Checkout.tree(repo, commit, opts);
});
}
return await using(async (ds) => {
let repo = ds(await Repository.open(repoDir));
let origin = ds(await Remote.lookup(repo, 'origin', () => {}));
let cb = {
credentials: () => {
d(`Returning ${token} for authentication token`);
return Cred.userpassPlaintextNew(token || '', 'x-oauth-basic');
},
certificateCheck: () => {
// Yolo
return 1;
}
};
await origin.connect(0, cb, null, null, null);
try {
return await using(async (ds) => {
d('Opening repo');
let repo = ds(await Repository.open(targetDir));
d('Looking up origin');
let origin = await Remote.lookup(repo, 'origin', () => {});
let refspec = 'refs/heads/master:refs/heads/master';
let pushopts: any = {
callbacks: {
credentials: () => {
d(`Returning ${token} for authentication token`);
return Cred.userpassPlaintextNew(token, 'x-oauth-basic');
},
certificateCheck: () => {
// Yolo
return 1;
}
}
}, (filenames) => {
if (!filenames) return
if (filenames.length > 0) {
const filePath = filenames[0]
const projectName = filePath.split('\/').reverse()[0]
Repository.open(filePath).then((repo) => {
db.get('projects').push({
name: projectName,
path: filePath,
}).value()
dispatch({
type: LOAD_PROJECT,
repo: repo,
})
dispatch(listProject())
let win = new BrowserWindow({
width: 1048,
height: 604,
})
win.loadURL(`file:\/\/${join(__dirname, `index.html#\/repo\/${projectName}/history`)}`)
win.show()
const runLightmerge = async (path, list, baseBranch) => {
io.emit(WS_EVENT.CLEAR);
const repo = await Repository.open(path);
const baseCommit = await repo.getBranchCommit(baseBranch);
repo.checkoutBranch('master', {});
const canWrite = await hsetnx(`${path}/lock`, 'lock', 1);
if (canWrite === 0) {
io.emit(WS_EVENT.MESSAGE, 'Other user is lightmerging, please wait!');
} else {
io.emit(WS_EVENT.MESSAGE, 'Start lightmerge');
}
io.emit(WS_EVENT.MESSAGE, `Overwrite lightmerge with ${baseBranch}`);
const signature = Signature.default(repo);
let currentBranch;
let conflictFiles;
let conflictBranch;
const runLightmerge = async (path, list) => {
const repo = await Repository.open(path);
const masterCommit = await repo.getMasterCommit();
const canWrite = await hsetnx(`${path}/lock`, 'lock', 1);
Log.debug(canWrite);
const CannotLightmerge = {
message: 'Other user is lightmerging, please wait!',
};
if (canWrite === 0) {
throw CannotLightmerge;
}
Log.debug('Overwrite lightmerge with master');
await repo.createBranch('lightmerge', masterCommit, true);
const signature = Signature.default(repo);
let conflictFiles;
await using(async (ds) => {
let repo = ds(await Repository.open(target));
Remote.setUrl(repo, 'origin', url);
});
}
const getBranchList = async (pathToRepo) => {
const repo = await Repository.open(pathToRepo);
const refs = await repo.getReferences(Reference.TYPE.LISTALL);
const list = await Promise.all(refs.reduce((total, ref) => total.concat(Branch.name(ref)), []));
return list || [];
};