@@ -13,25 +13,28 @@ main(load_setup(' better-branch '))
13
13
14
14
async function main ( config : z . infer < typeof Config > ) {
15
15
const branch_state = BranchState . parse ( { } ) ;
16
- const cache_user_name = get_user_from_cache ( )
17
- const user_name_required = config . branch_user . required
18
- const user_name = await p . text ( {
19
- message : `Type your git username ${ user_name_required ? '' : OPTIONAL_PROMPT } ${ CACHE_PROMPT } ` . trim ( ) ,
20
- placeholder : '' ,
21
- initialValue : cache_user_name ,
22
- validate : ( val ) => {
23
- if ( user_name_required && ! val ) return 'Please enter a username'
24
- }
25
- } )
26
- if ( p . isCancel ( user_name ) ) process . exit ( 0 )
27
- branch_state . user = user_name ?. replace ( / \s + / g, '-' ) ?. toLowerCase ( ) ?? '' ;
28
- set_user_cache ( branch_state . user )
29
16
30
- if ( config . commit_type . enable ) {
17
+ if ( config . branch_user . enable ) {
18
+ const cache_user_name = get_user_from_cache ( )
19
+ const user_name_required = config . branch_user . required
20
+ const user_name = await p . text ( {
21
+ message : `Type your git username ${ user_name_required ? '' : OPTIONAL_PROMPT } ${ CACHE_PROMPT } ` . trim ( ) ,
22
+ placeholder : '' ,
23
+ initialValue : cache_user_name ,
24
+ validate : ( val ) => {
25
+ if ( user_name_required && ! val ) return 'Please enter a username'
26
+ }
27
+ } )
28
+ if ( p . isCancel ( user_name ) ) process . exit ( 0 )
29
+ branch_state . user = user_name ?. replace ( / \s + / g, '-' ) ?. toLowerCase ( ) ?? '' ;
30
+ set_user_cache ( branch_state . user )
31
+ }
32
+
33
+ if ( config . branch_type . enable ) {
31
34
let initial_value = config . commit_type . initial_value
32
35
const commit_type = await p . select (
33
36
{
34
- message : `Select a commit type` ,
37
+ message : `Select a branch type` ,
35
38
initialValue : initial_value ,
36
39
options : config . commit_type . options ,
37
40
}
@@ -40,17 +43,19 @@ async function main(config: z.infer<typeof Config>) {
40
43
branch_state . type = commit_type ;
41
44
}
42
45
43
- const ticked_required = config . branch_ticket . required
44
- const ticket = await p . text ( {
45
- message : `Type ticket / issue number ${ ticked_required ? '' : OPTIONAL_PROMPT } ` . trim ( ) ,
46
- placeholder : '' ,
47
- validate : ( val ) => {
48
- if ( ticked_required && ! val ) return 'Please enter a ticket / issue'
49
- }
50
- } )
51
- if ( p . isCancel ( ticket ) ) process . exit ( 0 )
52
- branch_state . ticket = ticket ;
53
-
46
+ if ( config . branch_ticket . enable ) {
47
+ const ticked_required = config . branch_ticket . required
48
+ const ticket = await p . text ( {
49
+ message : `Type ticket / issue number ${ ticked_required ? '' : OPTIONAL_PROMPT } ` . trim ( ) ,
50
+ placeholder : '' ,
51
+ validate : ( val ) => {
52
+ if ( ticked_required && ! val ) return 'Please enter a ticket / issue'
53
+ }
54
+ } )
55
+ if ( p . isCancel ( ticket ) ) process . exit ( 0 )
56
+ branch_state . ticket = ticket ;
57
+ }
58
+
54
59
55
60
const description_max_length = config . branch_description . max_length
56
61
const description = await p . text ( {
0 commit comments