Skip to content

Commit

Permalink
Improve clone speed for big repos (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv authored Feb 7, 2022
1 parent b8c4abd commit 065a653
Show file tree
Hide file tree
Showing 71 changed files with 1,808 additions and 982 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
/dist
/yarn-error.log
.DS_Store
/src/test/tmp-mock-environments
/src/test/private/accessToken.txt
/src/services/git-test-temp
/src/test/_tmp_sandbox_

1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"parser": "typescript",
"semi": true,
"singleQuote": true
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"yarn.lock": true,
"coverage": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"CODE_OF_CONDUCT.md": true,
"github-schema.graphql": true,
"LICENSE.txt": true
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
Expand Down
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
},
"license": "MIT",
"scripts": {
"lint": "tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
"prepare": "husky install",
"postinstall": "test -f ./dist/scripts/runPostinstall.js && node ./dist/scripts/runPostinstall.js || echo 'Dist folder missing'",
"prepublishOnly": "tsc --project ./tsconfig.prod.json",
"test": "jest",
"test-private": "jest --config ./jest.config.private.js",
"test-mutation": "jest --config ./jest.config.mutation.js",
"postversion": "yarn extractPackageVersion && yarn build",
"prepare": "husky install",
"prepublishOnly": "yarn build",
"build": "tsc --project ./tsconfig.prod.json",
"extractPackageVersion": "node -p \"'export const PACKAGE_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | prettier > src/utils/packageVersion.ts",
"lint": "tsc --project ./tsconfig.test.json && eslint './**/*.{ts,js}'",
"start": "ts-node --transpile-only ./src/entrypoint.cli.ts",
"test-all": "yarn lint && jest --config ./jest.config.all.js",
"start": "ts-node --transpile-only ./src/entrypoint.cli.ts"
"test-mutation": "jest --config ./jest.config.mutation.js",
"test-private": "jest --config ./jest.config.private.js",
"test": "jest"
},
"lint-staged": {
"*.ts": [
Expand Down Expand Up @@ -60,7 +63,7 @@
},
"dependencies": {
"@octokit/rest": "^18.12.0",
"axios": "^0.24.0",
"axios": "^0.25.0",
"dedent": "^0.7.0",
"del": "^6.0.0",
"find-up": "^5.0.0",
Expand All @@ -72,38 +75,38 @@
"strip-json-comments": "^3.1.1",
"terminal-link": "^2.1.1",
"utility-types": "^3.10.0",
"winston": "^3.4.0",
"winston": "^3.5.1",
"yargs": "^17.3.1"
},
"devDependencies": {
"@types/core-js": "^2.5.5",
"@types/dedent": "^0.7.0",
"@types/inquirer": "^8.1.3",
"@types/inquirer": "^8.2.0",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.178",
"@types/node": "^17.0.8",
"@types/safe-json-stringify": "^1.1.2",
"@types/yargs": "^17.0.8",
"@types/yargs-parser": "^20.2.1",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.7.0",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-jest": "^26.0.0",
"eslint-plugin-prettier": "^4.0.0",
"graphql": "^16.2.0",
"graphql": "^16.3.0",
"graphql-config": "^4.1.0",
"graphql-tag": "^2.12.6",
"husky": "^7.0.4",
"jest": "^27.4.7",
"jest-snapshot-serializer-ansi": "^1.0.0",
"lint-staged": "^12.1.7",
"nock": "^13.2.2",
"lint-staged": "^12.3.3",
"nock": "^13.2.4",
"prettier": "^2.5.1",
"strip-ansi": "^6.0.1",
"ts-jest": "^27.1.3",
"ts-node": "^10.4.0",
"typescript": "^4.5.4"
"typescript": "^4.5.5"
}
}
20 changes: 12 additions & 8 deletions src/backportRun.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import chalk from 'chalk';
import ora from 'ora';
import yargs from 'yargs';
import yargsParser from 'yargs-parser';
import { ConfigFileOptions } from './options/ConfigOptions';
import { getOptions, ValidConfigOptions } from './options/options';
import { runSequentially, Result } from './runSequentially';
import { HandledError } from './services/HandledError';
import { getLogfilePath } from './services/env';
import { createStatusComment } from './services/github/v3/createStatusComment';
import { GithubV4Exception } from './services/github/v4/apiRequestV4';
import { consoleLog, initLogger, logger } from './services/logger';
import { Commit } from './services/sourceCommit/parseSourceCommit';
import { getCommits } from './ui/getCommits';
Expand All @@ -21,21 +22,25 @@ export type BackportResponse =
| {
status: 'failure';
commits: Commit[];
errorMessage: string;
error: Error;
error: Error | HandledError;
};

export async function backportRun(
processArgs: string[],
optionsFromModule: ConfigFileOptions = {}
): Promise<BackportResponse> {
const argv = yargs(processArgs).argv as any as ConfigFileOptions;
const argv = yargsParser(processArgs) as ConfigFileOptions;
const ci = argv.ci ?? optionsFromModule.ci;
const logFilePath = argv.logFilePath ?? optionsFromModule.logFilePath;

initLogger({ ci, logFilePath });

const spinner = ora().start('Initializing...');
// don't show spinner for yargs commands that exit the process without stopping the spinner first
const spinner = ora();

if (!argv.help && !argv.version) {
spinner.start('Initializing...');
}

let options: ValidConfigOptions | null = null;
let commits: Commit[] = [];
Expand Down Expand Up @@ -63,7 +68,6 @@ export async function backportRun(
const backportResponse: BackportResponse = {
status: 'failure',
commits,
errorMessage: e.message,
error: e,
};

Expand All @@ -74,7 +78,7 @@ export async function backportRun(
});
}

if (e instanceof HandledError) {
if (e instanceof HandledError || e instanceof GithubV4Exception) {
consoleLog(e.message);
} else if (e instanceof Error) {
// output
Expand All @@ -94,7 +98,7 @@ export async function backportRun(
)
);

// log file
// write to log
logger.info('Unknown error:', e);
}

Expand Down
Loading

0 comments on commit 065a653

Please sign in to comment.