|
| 1 | +class GitflowToolkit < Formula |
| 2 | + desc "CLI tool for standardizing git commits following Angular commit specification" |
| 3 | + homepage "https://github.com/mritd/gitflow-toolkit" |
| 4 | + license "MIT" |
| 5 | + |
| 6 | + # Get latest version from GitHub API |
| 7 | + latest_version = JSON.parse( |
| 8 | + URI.open("https://api.github.com/repos/mritd/gitflow-toolkit/releases/latest").read |
| 9 | + )["tag_name"].delete_prefix("v") |
| 10 | + |
| 11 | + version latest_version |
| 12 | + |
| 13 | + # Fetch checksums from release |
| 14 | + checksums_url = "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/checksums.txt" |
| 15 | + checksums = URI.open(checksums_url).read.lines.to_h { |l| l.strip.split(" ").reverse } |
| 16 | + |
| 17 | + on_macos do |
| 18 | + on_intel do |
| 19 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-darwin-amd64" |
| 20 | + sha256 checksums["gitflow-toolkit-darwin-amd64"] |
| 21 | + end |
| 22 | + |
| 23 | + on_arm do |
| 24 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-darwin-arm64" |
| 25 | + sha256 checksums["gitflow-toolkit-darwin-arm64"] |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + on_linux do |
| 30 | + on_intel do |
| 31 | + if Hardware::CPU.is_64_bit? |
| 32 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-linux-amd64" |
| 33 | + sha256 checksums["gitflow-toolkit-linux-amd64"] |
| 34 | + else |
| 35 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-linux-386" |
| 36 | + sha256 checksums["gitflow-toolkit-linux-386"] |
| 37 | + end |
| 38 | + end |
| 39 | + |
| 40 | + on_arm do |
| 41 | + if Hardware::CPU.is_64_bit? |
| 42 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-linux-arm64" |
| 43 | + sha256 checksums["gitflow-toolkit-linux-arm64"] |
| 44 | + else |
| 45 | + url "https://github.com/mritd/gitflow-toolkit/releases/download/v#{version}/gitflow-toolkit-linux-armv7" |
| 46 | + sha256 checksums["gitflow-toolkit-linux-armv7"] |
| 47 | + end |
| 48 | + end |
| 49 | + end |
| 50 | + |
| 51 | + def install |
| 52 | + binary_name = stable.url.split("/").last |
| 53 | + bin.install binary_name => "gitflow-toolkit" |
| 54 | + |
| 55 | + # Create git subcommand symlinks |
| 56 | + %w[ci ps feat fix docs style refactor test chore perf hotfix].each do |cmd| |
| 57 | + bin.install_symlink "gitflow-toolkit" => "git-#{cmd}" |
| 58 | + end |
| 59 | + end |
| 60 | + |
| 61 | + def caveats |
| 62 | + <<~EOS |
| 63 | + Git subcommands have been installed: |
| 64 | + git ci - Interactive commit |
| 65 | + git ps - Push with TUI |
| 66 | + git feat - Create feature branch |
| 67 | + git fix - Create fix branch |
| 68 | + ... and more |
| 69 | +
|
| 70 | + For AI-powered commit generation, configure your LLM: |
| 71 | + git config --global gitflow.llm-api-key "your-api-key" |
| 72 | + EOS |
| 73 | + end |
| 74 | + |
| 75 | + test do |
| 76 | + assert_match version.to_s, shell_output("#{bin}/gitflow-toolkit -v") |
| 77 | + end |
| 78 | +end |
0 commit comments