diff --git a/src/index.ts b/src/index.ts index 08213c3..e9f0b3a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,6 +30,8 @@ const args = yargs const loz = new Loz(); async function handleLozCommand(): Promise { + if (args.attribution) loz.attribution = true; + // If the stdin is a TTY // when runnig unit tests for running Linux commands, stdin is not a TTY // so we need isRunningInMocha to check if we are running unit tests. @@ -43,8 +45,6 @@ async function handleLozCommand(): Promise { // Input from a pipe if (args.git) { await handleCodeDiffFromPipe(); - } else if (args.attribution) { - loz.attribution = true; } else { //console.log("Run loz like this: git diff | loz --git"); if (args.prompt !== undefined) { diff --git a/test/git.test.ts b/test/git.test.ts index 5b98efe..1e04b2a 100644 --- a/test/git.test.ts +++ b/test/git.test.ts @@ -70,6 +70,17 @@ describe("Test git operations", function () { execSync("sed -i 's/Hell/Hello/g' hello.c"); const log = execSync(`git diff | node ${LOZ_BIN} -g`).toString(); expect(log).to.include("typo"); + // Do not append "Generated by Model Name" to the commit message by default. + expect(log.indexOf("Generated by")).equal(-1); + }); + + // git diff | loz -g -a + it("append 'Generated by gpt-3.5-turbo'", function () { + this.timeout(5000); + const log = execSync(`git diff | node ${LOZ_BIN} -g -a`).toString(); + expect(log).to.include("typo"); + // Append "Generated by Model Name" to the commit message. (-a option is used) + expect(log).to.include("Generated by"); }); // LOZ=true git commit