diff --git a/Formula/a/aicommit2.rb b/Formula/a/aicommit2.rb new file mode 100644 index 0000000000000..0ac3f4b46b78d --- /dev/null +++ b/Formula/a/aicommit2.rb @@ -0,0 +1,35 @@ +class Aicommit2 < Formula + desc "Reactive CLI that generates commit messages for Git and Jujutsu with AI" + homepage "https://github.com/tak-bro/aicommit2" + url "https://registry.npmjs.org/aicommit2/-/aicommit2-2.4.11.tgz" + sha256 "f70af3cebb289fbc83ef04adad59be45014e2c068de0a6b52328e831daaf330e" + license "MIT" + + bottle do + sha256 cellar: :any_skip_relocation, all: "9fe23b4d59bc66c7ad548597a4a1924c199059535324aa66bbeb55051d707496" + end + + depends_on "node" + + def install + system "npm", "install", *std_npm_args + bin.install_symlink Dir["#{libexec}/bin/*"] + end + + test do + assert_match version.to_s, shell_output("#{bin}/aicommit2 --version") + assert_match version.to_s, shell_output("#{bin}/aic2 --version") + + assert_match "Not in a Git repository", shell_output("#{bin}/aicommit2 2>&1", 1) + + system "git", "init" + assert_match "No staged changes found", shell_output("#{bin}/aicommit2 2>&1", 1) + + (testpath/"test.txt").write "test content" + system "git", "add", "test.txt" + + assert_match "Please set at least one API key", shell_output("#{bin}/aicommit2 2>&1", 1) + shell_output("#{bin}/aicommit2 config set OPENAI.key=sk-test") + assert_match "key: 'sk-test'", shell_output("#{bin}/aicommit2 config get OPENAI") + end +end