refactor(dev-infra): move getRepoBaseDir() to GitClient (#41527)

As `getRepoBaseDir()` relies on git, it should be a method on `GitClient` for retrieval
rather than its own utility outside of the common GitClient used for all git ineractions.

PR Close #41527
This commit is contained in:
Joey Perrott
2021-04-12 14:50:50 -07:00
committed by Andrew Kushnir
parent 5332a4a919
commit dd4c3dba3f
18 changed files with 882 additions and 438 deletions
@@ -8,15 +8,16 @@
import {readFileSync} from 'fs';
import {resolve} from 'path';
import {getRepoBaseDir} from '../../utils/config';
import {error, green, info, log, red, yellow} from '../../utils/console';
import {GitClient} from '../../utils/git/index';
import {deleteCommitMessageDraft, saveCommitMessageDraft} from '../restore-commit-message/commit-message-draft';
import {printValidationErrors, validateCommitMessage} from '../validate';
/** Validate commit message at the provided file path. */
export function validateFile(filePath: string, isErrorMode: boolean) {
const commitMessage = readFileSync(resolve(getRepoBaseDir(), filePath), 'utf8');
const git = GitClient.getInstance();
const commitMessage = readFileSync(resolve(git.baseDir, filePath), 'utf8');
const {valid, errors} = validateCommitMessage(commitMessage);
if (valid) {
info(`${green('√')} Valid commit message`);