File tree Expand file tree Collapse file tree 3 files changed +52
-6
lines changed Expand file tree Collapse file tree 3 files changed +52
-6
lines changed Original file line number Diff line number Diff line change @@ -88,4 +88,30 @@ export class Git {
88
88
) ;
89
89
} ) ;
90
90
}
91
+
92
+ public configLoz ( name : string , value ?: string ) : Promise < string > {
93
+ return new Promise ( ( resolve , reject ) => {
94
+ const gitCommand =
95
+ value === undefined
96
+ ? `git config loz.${ name } `
97
+ : `git config loz.${ name } ${ value } ` ;
98
+
99
+ exec (
100
+ gitCommand ,
101
+ ( error : Error | null , stdout : string , stderr : string ) => {
102
+ if ( error ) {
103
+ console . error ( `Error: ${ error . message } ` ) ;
104
+ reject ( error . message ) ;
105
+ return ;
106
+ }
107
+ if ( stderr ) {
108
+ console . error ( `Stderr: ${ stderr } ` ) ;
109
+ reject ( stderr ) ;
110
+ return ;
111
+ }
112
+ resolve ( stdout ) ;
113
+ } ,
114
+ ) ;
115
+ } ) ;
116
+ }
91
117
}
Original file line number Diff line number Diff line change @@ -86,9 +86,11 @@ async function handleCodeDiffFromPipe(): Promise<void> {
86
86
return ;
87
87
}
88
88
89
- process . stdout . write (
90
- completion . content + "\n\nGenerated by " + completion . model + "\n" ,
91
- ) ;
89
+ if ( loz . attribution ) {
90
+ process . stdout . write (
91
+ completion . content + "\n\nGenerated by " + completion . model + "\n" ,
92
+ ) ;
93
+ }
92
94
} ) ;
93
95
}
94
96
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export class Loz {
37
37
configPath : string ;
38
38
config : Config = new Config ( ) ;
39
39
git : Git = new Git ( ) ;
40
+ attribution : boolean = false ;
40
41
41
42
constructor ( ) {
42
43
this . defaultSettings = {
@@ -60,6 +61,18 @@ export class Loz {
60
61
if ( ! fs . existsSync ( LOG_DEV_PATH ) ) {
61
62
fs . mkdirSync ( LOG_DEV_PATH ) ;
62
63
}
64
+
65
+ const attributionValue = await this . git . configLoz ( "attribution" ) ;
66
+ if ( attributionValue === "" ) {
67
+ this . git . configLoz ( "attribution" , "false" ) ;
68
+ this . attribution = false ;
69
+ } else {
70
+ if ( attributionValue . trimEnd ( ) === "true" ) {
71
+ this . attribution = true ;
72
+ } else {
73
+ this . attribution = false ;
74
+ }
75
+ }
63
76
}
64
77
65
78
await this . initLLMfromConfig ( ) ;
@@ -149,9 +162,14 @@ export class Loz {
149
162
}
150
163
151
164
try {
152
- await this . git . commit (
153
- complete . content + "\n\nGenerated by " + complete . model ,
154
- ) ;
165
+ if ( this . attribution ) {
166
+ await this . git . commit (
167
+ complete . content + "\n\nGenerated by " + complete . model ,
168
+ ) ;
169
+ } else {
170
+ await this . git . commit ( complete . content ) ;
171
+ }
172
+
155
173
const commitHEAD = await this . git . showHEAD ( ) ;
156
174
console . log ( "\n# Generated commit message: \n" ) ;
157
175
console . log ( commitHEAD ) ;
You can’t perform that action at this time.
0 commit comments