11import { inject , injectable } from 'inversify' ;
2- import { IGitBranchFromCommitCommandHandler , IGitCheckoutCommandHandler , IGitCherryPickCommandHandler , IGitCommitViewDetailsCommandHandler , IGitCompareCommandHandler , IGitMergeCommandHandler , IGitRebaseCommandHandler , IGitRevertCommandHandler } from '../commandHandlers/types' ;
2+ import { IGitBranchFromCommitCommandHandler , IGitCheckoutCommandHandler , IGitCherryPickCommandHandler , IGitCommitViewDetailsCommandHandler , IGitCompareCommandHandler , IGitMergeCommandHandler , IGitRebaseCommandHandler , IGitRevertCommandHandler , IGitTagFromCommitCommandHandler } from '../commandHandlers/types' ;
33import { CheckoutCommand } from '../commands/commit/checkout' ;
44import { CherryPickCommand } from '../commands/commit/cherryPick' ;
55import { CompareCommand } from '../commands/commit/compare' ;
66import { CreateBranchCommand } from '../commands/commit/createBranch' ;
7+ import { CreateTagCommand } from '../commands/commit/createTag' ;
78import { MergeCommand } from '../commands/commit/merge' ;
89import { RebaseCommand } from '../commands/commit/rebase' ;
910import { RevertCommand } from '../commands/commit/revert' ;
@@ -15,6 +16,7 @@ import { ICommitCommandFactory } from './types';
1516@injectable ( )
1617export class CommitCommandFactory implements ICommitCommandFactory {
1718 constructor ( @inject ( IGitBranchFromCommitCommandHandler ) private branchCreationCommandHandler : IGitBranchFromCommitCommandHandler ,
19+ @inject ( IGitTagFromCommitCommandHandler ) private tagCreationCommandHandler : IGitTagFromCommitCommandHandler ,
1820 @inject ( IGitCherryPickCommandHandler ) private cherryPickHandler : IGitCherryPickCommandHandler ,
1921 @inject ( IGitCheckoutCommandHandler ) private checkoutHandler : IGitCheckoutCommandHandler ,
2022 @inject ( IGitCompareCommandHandler ) private compareHandler : IGitCompareCommandHandler ,
@@ -24,7 +26,6 @@ export class CommitCommandFactory implements ICommitCommandFactory {
2426 @inject ( IGitCommitViewDetailsCommandHandler ) private viewChangeLogHandler : IGitCommitViewDetailsCommandHandler ) { }
2527 public async createCommands ( commit : CommitDetails ) : Promise < ICommand < CommitDetails > [ ] > {
2628 const commands : ICommand < CommitDetails > [ ] = [
27- new CreateBranchCommand ( commit , this . branchCreationCommandHandler ) ,
2829 new CherryPickCommand ( commit , this . cherryPickHandler ) ,
2930 new CheckoutCommand ( commit , this . checkoutHandler ) ,
3031 new ViewDetailsCommand ( commit , this . viewChangeLogHandler ) ,
@@ -43,4 +44,19 @@ export class CommitCommandFactory implements ICommitCommandFactory {
4344 . filter ( cmd => ! ! cmd )
4445 . map ( cmd => cmd ! ) ;
4546 }
47+
48+ public async createNewCommands ( commit : CommitDetails ) : Promise < ICommand < CommitDetails > [ ] > {
49+ const commands : ICommand < CommitDetails > [ ] = [
50+ new CreateBranchCommand ( commit , this . branchCreationCommandHandler ) ,
51+ new CreateTagCommand ( commit , this . tagCreationCommandHandler )
52+ ] ;
53+
54+ return ( await Promise . all ( commands . map ( async cmd => {
55+ const result = cmd . preExecute ( ) ;
56+ const available = typeof result === 'boolean' ? result : await result ;
57+ return available ? cmd : undefined ;
58+ } ) ) )
59+ . filter ( cmd => ! ! cmd )
60+ . map ( cmd => cmd ! ) ;
61+ }
4662}
0 commit comments