Skip to content

Commit

Permalink
fix(contributors): Fix contributors, authors is experiment (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feverqwe authored Jul 31, 2023
1 parent 25f0585 commit 7f2e395
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
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

0 comments on commit 7f2e395

Please sign in to comment.