Skip to content

Commit

Permalink
Add attribution flag to loz command
Browse files Browse the repository at this point in the history
Add attribution flag to loz command for better tracking of changes.

Generated by gpt-3.5-turbo
  • Loading branch information
joone committed Mar 19, 2024
1 parent 4136fb9 commit ffcfd35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const args = yargs
const loz = new Loz();

async function handleLozCommand(): Promise<void> {
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.
Expand All @@ -43,8 +45,6 @@ async function handleLozCommand(): Promise<void> {
// 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) {
Expand Down
11 changes: 11 additions & 0 deletions test/git.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffcfd35

Please sign in to comment.