Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(agoric-cli): Improve git clone efficiency #8057

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/agoric-cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
dappBranch = ['-b', opts.dappBranch];
}

const shallow = ['--depth', '1', '--shallow-submodules'];
const exitStatus = await pspawn(
'git',
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
['clone', '--origin=upstream', ...shallow, dappURL, DIR, ...dappBranch],
{
stdio: 'inherit',
},
Expand Down
10 changes: 6 additions & 4 deletions packages/cosmic-swingset/test/scenario2.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ const onlyStderr = ['ignore', 'ignore', 'inherit'];
const noOutput = ['ignore', 'ignore', 'ignore'];
// const noisyDebug = ['ignore', 'inherit', 'inherit'];

export const pspawn =
(bin, { spawn, cwd }) =>
(args = [], opts = {}) => {
export const pspawn = (bin, { spawn, cwd }) => {
return (args = [], opts = {}) => {
/** @type {import('child_process').ChildProcess} */
let child;
const exit = new Promise((resolve, reject) => {
// console.debug('spawn', bin, args, { cwd: makefileDir, ...opts });
child = spawn(bin, args, { cwd, ...opts });
child.addListener('exit', code => {
if (code !== 0) {
reject(Error(`exit ${code} from: ${bin} ${args}`));
// TODO: Include ~3 lines from child.stderr or child.stdout if present.
// see https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
reject(Error(`exit ${code} from command: ${bin} ${args}`));
return;
}
resolve(0);
Expand All @@ -34,6 +35,7 @@ export const pspawn =
// @ts-expect-error child is set in the Promise constructor
return { kill, child, exit };
};
};

/**
* Shared state for tests using scenario2 chain in ../
Expand Down
Loading