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:
committed by
Andrew Kushnir
parent
5332a4a919
commit
dd4c3dba3f
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user