mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
refactor: Improve file extension handling in CodeRepositoryUtil
The CodeRepositoryUtil class in CodeRepository.ts has been refactored to improve the handling of file extensions. The changes include: - Simplifying the logic for skipping files with unsupported extensions - Adding support for accepted file extensions in the getFilesInDirectory method These improvements enhance the functionality and maintainability of the code.
This commit is contained in:
parent
d153ad9bf7
commit
21973401fb
@ -57,23 +57,7 @@ export default class CodeRepositoryUtil {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (
|
||||
data.acceptedFileExtensions &&
|
||||
data.acceptedFileExtensions.length > 0
|
||||
) {
|
||||
let shouldSkip: boolean = true;
|
||||
|
||||
for (const fileExtension of data.acceptedFileExtensions) {
|
||||
if (fileName.endsWith(fileExtension)) {
|
||||
shouldSkip = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSkip) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const filePath: string = LocalFile.sanitizeFilePath(
|
||||
`${directoryPath}/${fileName}`
|
||||
@ -92,6 +76,24 @@ export default class CodeRepositoryUtil {
|
||||
LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`)
|
||||
);
|
||||
continue;
|
||||
}else{
|
||||
if (
|
||||
data.acceptedFileExtensions &&
|
||||
data.acceptedFileExtensions.length > 0
|
||||
) {
|
||||
let shouldSkip: boolean = true;
|
||||
|
||||
for (const fileExtension of data.acceptedFileExtensions) {
|
||||
if (fileName.endsWith(fileExtension)) {
|
||||
shouldSkip = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldSkip) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const gitCommitHash: string = await this.getGitCommitHashForFile({
|
||||
@ -127,6 +129,7 @@ export default class CodeRepositoryUtil {
|
||||
await this.getFilesInDirectory({
|
||||
directoryPath: data.directoryPath,
|
||||
repoPath: data.repoPath,
|
||||
acceptedFileExtensions: data.acceptedFileExtensions,
|
||||
});
|
||||
|
||||
files = {
|
||||
|
Loading…
Reference in New Issue
Block a user