@@ -269,32 +269,49 @@ export class GitLinkAPIService implements ICodeAPIService {
269269 }
270270
271271 async getFileBlame ( repo : IRepositoryModel , path : string ) {
272- // const blames = await this.request<API.ResponseFileBlame>(
273- // `/api/v1/${this.getProjectPath(repo)}/blame?sha=${repo.commit}&filepath=${path}`,
274- // {
275- // responseType: 'json',
276- // }
277- // );
278- // blames.blame_parts.map((blame) => {
279- // const commit = blame.commit;
280-
281- // return {
282- // commit: {
283- // id: commit.sha,
284- // auther_name: commit.committer.name,
285- // auther_email: commit.committer?.email,
286- // authored_date: commit.authored_time,
287- // committed_date: commit.commited_time,
288- // message: commit.commit_message,
289- // author: {
290- // avatar_url: commit.committer.image_url,
291- // },
292- // },
293- // lines: [],
294- // };
295- // });
296-
297- return Uint8Array . from ( [ ] ) ;
272+ const blames = await this . request < API . ResponseFileBlame > (
273+ `/api/v1/${ this . getProjectPath ( repo ) } /blame?sha=${ repo . commit } &filepath=${ path } ` ,
274+ {
275+ responseType : 'json' ,
276+ }
277+ ) ;
278+ const blameHash = { } ;
279+ const blamePart : API . gitlensBlame [ ] = [ ] ;
280+
281+ blames . blame_parts . forEach ( ( blame ) => {
282+ const commit = blame . commit ;
283+ if ( blameHash [ commit . sha ] ) {
284+ const bla = blamePart . find ( ( b ) => b . commit . id === blame . commit . sha ) as API . gitlensBlame ;
285+ bla . lines . push ( {
286+ current_number : blame . current_number ,
287+ effect_line : blame . effect_line ,
288+ previous_number : blame . previous_number ,
289+ } ) ;
290+ } else {
291+ blameHash [ commit . sha ] = true ;
292+ blamePart . push ( {
293+ commit : {
294+ id : commit . sha ,
295+ author_name : commit . committer . name ,
296+ author_email : commit . committer ?. email ,
297+ authored_date : commit . authored_time ,
298+ committed_date : commit . commited_time ,
299+ message : commit . commit_message ,
300+ author : {
301+ avatar_url : commit . committer . image_url ,
302+ } ,
303+ } ,
304+ lines : [
305+ {
306+ current_number : blame . current_number ,
307+ effect_line : blame . effect_line ,
308+ previous_number : blame . previous_number ,
309+ } ,
310+ ] ,
311+ } ) ;
312+ }
313+ } ) ;
314+ return new TextEncoder ( ) . encode ( JSON . stringify ( blamePart ) ) ;
298315 }
299316
300317 async getCommits ( repo : IRepositoryModel , params : CommitParams ) {
0 commit comments