@@ -6,28 +6,16 @@ script({
6
6
description : "Generate a commit message for all staged changes" ,
7
7
} )
8
8
9
- // TODO: update this diff command to match your workspace
10
- const diffCmd = "git diff --cached -- . :!**/genaiscript.d.ts"
11
-
12
9
// Check for staged changes and stage all changes if none are staged
13
- let diff = await host . exec ( diffCmd )
14
- if ( ! diff . stdout ) {
15
- /**
16
- * Ask user to stage all changes if none are staged
17
- */
18
- const stage = await host . confirm ( "No staged changes. Stage all changes?" , {
19
- default : true ,
20
- } )
21
- if ( stage ) {
22
- // Stage all changes and recompute diff
23
- await host . exec ( "git add ." )
24
- diff = await host . exec ( diffCmd )
25
- }
26
- if ( ! diff . stdout ) cancel ( "no staged changes" )
27
- }
10
+ const diff = await git . diff ( {
11
+ staged : true ,
12
+ excludedPaths : "**/genaiscript.d.ts" ,
13
+ askStageOnEmpty : true ,
14
+ } )
15
+ if ( ! diff ) cancel ( "no staged changes" )
28
16
29
17
// show diff in the console
30
- console . log ( diff . stdout )
18
+ console . log ( diff )
31
19
32
20
let choice
33
21
let message
@@ -79,9 +67,9 @@ Please generate a concise, one-line commit message for these changes.
79
67
}
80
68
// Regenerate message
81
69
if ( choice === "commit" && message ) {
82
- console . log ( ( await host . exec ( "git" , [ "commit" , "-m" , message ] ) ) . stdout )
70
+ console . log ( await git . exec ( [ "commit" , "-m" , message ] ) )
83
71
if ( await host . confirm ( "Push changes?" , { default : true } ) )
84
- console . log ( ( await host . exec ( "git push" ) ) . stdout )
72
+ console . log ( await git . exec ( "push" ) )
85
73
break
86
74
}
87
75
} while ( choice !== "commit" )
0 commit comments