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

fix(contributors): Fix contributors, authors is experiment #523

Merged
merged 6 commits into from
Jul 31, 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
12 changes: 0 additions & 12 deletions src/vcs-connector/client/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import {
GithubUserDTO,
} from '../connector-models';
import {validateConnectorFields} from '../connector-validator';
import {logger} from '../../utils';

interface ResponseError extends Error {
status: number;
}

async function getRepoUser(octokit: Octokit, username: string): Promise<GithubUserDTO | null> {
try {
Expand Down Expand Up @@ -46,14 +41,7 @@ async function getRepoCommitByHash(httpClientByToken: Octokit, hashCommit: strin

return commit.data;
} catch (error) {
if (
(error as ResponseError).status === 422 && /No commit found for SHA/i.test((error as ResponseError).message)
) {
logger.info(`Error: ${error}`);
}

log.warn(`Getting commit by sha has been failed for GitHub. SHA commit: ${hashCommit}. Error: ${error}`);

return null;
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/vcs-connector/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from '../constants';
import {addSlashPrefix, logger} from '../utils';
import {validateConnectorFields} from './connector-validator';
import process from 'process';

const MAX_CONCURRENCY = 99;

Expand Down Expand Up @@ -98,14 +99,18 @@ async function getAllContributorsTocFiles(httpClientByToken: Octokit): Promise<v

try {
await simpleGit(options).raw('worktree', 'add', '-b', tmpMasterBranch, masterDir, 'origin/master');
const fullRepoLogString = await simpleGit(options).raw(
const fullRepoLogString = await simpleGit({
baseDir: join(rootInput, masterDir),
}).raw(
'log',
`${FIRST_COMMIT_FROM_ROBOT_IN_GITHUB}..HEAD`,
'--pretty=format:%ae, %an, %H',
'--name-only',
);
const repoLogs = fullRepoLogString.split('\n\n');
await matchAuthorsForEachPath(repoLogs, httpClientByToken);
if (process.env.ENABLE_EXPERIMANTAL_AUTHORS) {
await matchAuthorsForEachPath(repoLogs, httpClientByToken);
}
await matchContributionsForEachPath(repoLogs, httpClientByToken);
} finally {
await simpleGit(options).raw('worktree', 'remove', masterDir);
Expand Down