Skip to content

Commit d46eae5

Browse files
committed
Enable attribution check before committing changes
Add a check to enable attribution before committing changes to Git. This ensures that the commit message includes proper attribution if enabled. Generated by gpt-3.5-turbo
1 parent a23188e commit d46eae5

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ async function handleCodeDiffFromPipe(): Promise<void> {
8686
return;
8787
}
8888

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+
}
9294
});
9395
}
9496

src/loz.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class Loz {
3737
configPath: string;
3838
config: Config = new Config();
3939
git: Git = new Git();
40+
attribution: boolean = false;
4041

4142
constructor() {
4243
this.defaultSettings = {
@@ -106,6 +107,19 @@ export class Loz {
106107

107108
this.defaultSettings.model =
108109
this.config.get("model")?.value || DEFAULT_OPENAI_MODEL;
110+
111+
// Check if the attribution is enabled
112+
const attributionValue = this.config.get("attribution")?.value;
113+
if (!attributionValue) {
114+
this.config.set("attribution", "false");
115+
this.attribution = false;
116+
} else {
117+
if (attributionValue === "true") {
118+
this.attribution = true;
119+
} else {
120+
this.attribution = false;
121+
}
122+
}
109123
}
110124

111125
private checkAPI(): string | undefined {
@@ -149,9 +163,14 @@ export class Loz {
149163
}
150164

151165
try {
152-
await this.git.commit(
153-
complete.content + "\n\nGenerated by " + complete.model,
154-
);
166+
if (this.attribution) {
167+
await this.git.commit(
168+
complete.content + "\n\nGenerated by " + complete.model,
169+
);
170+
} else {
171+
await this.git.commit(complete.content);
172+
}
173+
155174
const commitHEAD = await this.git.showHEAD();
156175
console.log("\n# Generated commit message: \n");
157176
console.log(commitHEAD);

0 commit comments

Comments
 (0)