diff --git a/Formula/aicommits.rb b/Formula/aicommits.rb new file mode 100644 index 00000000000000..0dc6deb2f74be1 --- /dev/null +++ b/Formula/aicommits.rb @@ -0,0 +1,28 @@ +require "language/node" + +class Aicommits < Formula + desc "Writes your git commit messages for you with AI" + homepage "https://github.com/Nutlope/aicommits" + url "https://registry.npmjs.org/aicommits/-/aicommits-1.5.1.tgz" + sha256 "cc2d9011a3ef1eb7317078c9154753412f3cb42f8a73dccc1cd8f84744c57a72" + license "MIT" + + depends_on "node" + + def install + system "npm", "install", *Language::Node.std_npm_install_args(libexec) + bin.install_symlink Dir["#{libexec}/bin/*"] + end + + test do + assert_match "The current directory must be a Git repository!", shell_output("#{bin}/aicommits", 1) + + system "git", "init" + assert_match "No staged changes found. Make sure to stage your changes with `git add`.", + shell_output("#{bin}/aicommits", 1) + touch "test.txt" + system "git", "add", "test.txt" + assert_match "Please set your OpenAI API key via `aicommits config set OPENAI_KEY=`", + shell_output("#{bin}/aicommits", 1) + end +end