File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 11import type { CommitMsgFileInterface } from "../interfaces/commit-msg-file.interface.ts" ;
22import type { FormatUseCase } from "./format.use-case.ts" ;
3+ import type { GetCommitFilesUseCase } from "./get-commit-files.use-case.ts" ;
34
45export class EditUseCase {
56 constructor (
67 private readonly formatUseCase : FormatUseCase ,
78 private readonly commitMsgFile : CommitMsgFileInterface ,
9+ private readonly getCommitFilesUseCase : GetCommitFilesUseCase ,
810 ) { }
911
1012 async execute ( commitMsgFilePath : string ) : Promise < void > {
13+ const commitFiles = await this . getCommitFilesUseCase . execute ( {
14+ commitables : true ,
15+ } ) ;
1116 const rawMessage = await this . commitMsgFile . read ( commitMsgFilePath ) ;
12- const finalMessage = await this . formatUseCase . execute ( { rawMessage } ) ;
17+ const finalMessage = await this . formatUseCase . execute ( {
18+ rawMessage,
19+ commitFiles,
20+ } ) ;
1321 await this . commitMsgFile . write ( finalMessage ) ;
1422 }
1523}
Original file line number Diff line number Diff line change @@ -46,7 +46,17 @@ npx --no -- committier edit $1`,
4646 const configService = new ConfigService ( configLoader ) ;
4747 const config = await configService . getConfig ( ) ;
4848 const format = new FormatUseCase ( config ) ;
49- const edit = new EditUseCase ( format , commitMsgFile ) ;
49+ const commitFileRepository = new GitCommitFileRepository (
50+ ! ! config . autoScope || ! ! config . defaultDescription ,
51+ ) ;
52+ const getCommitFilesUseCase = new GetCommitFilesUseCase (
53+ commitFileRepository ,
54+ ) ;
55+ const edit = new EditUseCase (
56+ format ,
57+ commitMsgFile ,
58+ getCommitFilesUseCase ,
59+ ) ;
5060 await edit . execute ( filePath ) ;
5161 } ,
5262 )
@@ -73,7 +83,7 @@ npx --no -- committier edit $1`,
7383 const config = await configService . getConfig ( ) ;
7484 const format = new FormatUseCase ( config ) ;
7585 const commitFileRepository = new GitCommitFileRepository (
76- ! ! config . autoScope ,
86+ ! ! config . autoScope || ! ! config . defaultDescription ,
7787 ) ;
7888 const getCommitFilesUseCase = new GetCommitFilesUseCase (
7989 commitFileRepository ,
You can’t perform that action at this time.
0 commit comments