1
- import * as fs from "node:fs" ;
2
1
import * as path from "node:path" ;
3
2
import { errorMessages , repoPath } from "../lib/constants.ts" ;
4
3
import { logError } from "../lib/Logger.ts" ;
5
4
import CommandService from "./commandService.ts" ;
5
+ import FileSystemService from "./fileSystemService.ts" ;
6
6
import GitService from "./gitService.ts" ;
7
7
8
8
type BlameInfo = {
@@ -15,10 +15,10 @@ type BlameInfo = {
15
15
} ;
16
16
17
17
const GitBlameAnalyzer = {
18
- getGitBlame ( filePath : string ) : BlameInfo [ ] {
18
+ async getGitBlame ( filePath : string ) : Promise < BlameInfo [ ] > {
19
19
try {
20
20
const absoluteFilePath = path . resolve ( repoPath as string , filePath ) ;
21
- if ( ! fs . existsSync ( absoluteFilePath ) ) {
21
+ if ( ! ( await FileSystemService . fileExists ( absoluteFilePath ) ) ) {
22
22
throw new Error ( `${ errorMessages . fileNotFound } : ${ absoluteFilePath } ` ) ;
23
23
}
24
24
@@ -74,7 +74,7 @@ const GitBlameAnalyzer = {
74
74
executeGitBlame ( filePath : string ) : string {
75
75
const { ok : output , error } = CommandService . execute (
76
76
"git" ,
77
- [ "blame" , "--line-porcelain" , filePath ] ,
77
+ [ "blame" , "--line-porcelain" , filePath . replaceAll ( '"' , "" ) ] ,
78
78
repoPath
79
79
) ;
80
80
@@ -92,7 +92,7 @@ const GitBlameAnalyzer = {
92
92
if ( error !== undefined ) throw error ;
93
93
return output . stdout ;
94
94
} ,
95
- analyzeChanges ( filePath : string ) : string {
95
+ async analyzeChanges ( filePath : string ) : Promise < string > {
96
96
try {
97
97
// First check if file is deleted or new, as these don't need blame analysis
98
98
// Use git status to check file state
@@ -107,7 +107,7 @@ const GitBlameAnalyzer = {
107
107
}
108
108
109
109
// For existing files, we need to get blame info
110
- const blame = GitBlameAnalyzer . getGitBlame ( normalizedPath ) ;
110
+ const blame = await GitBlameAnalyzer . getGitBlame ( normalizedPath ) ;
111
111
112
112
const diff = GitBlameAnalyzer . getDiff ( normalizedPath ) ;
113
113
0 commit comments