diff --git a/Formula/ehco.rb b/Formula/ehco.rb index 6f56e3c81c1a5..4f744433d7b4d 100644 --- a/Formula/ehco.rb +++ b/Formula/ehco.rb @@ -1,8 +1,9 @@ class Ehco < Formula desc "Network relay tool and a typo :)" homepage "https://github.com/Ehco1996/ehco" - url "https://github.com/Ehco1996/ehco/archive/refs/tags/v1.0.7.tar.gz" - sha256 "d6384cdb31befcf9a198dd1be6c0073e9fabb6823f2f92df63bb50fb14ec6ff1" + url "https://github.com/Ehco1996/ehco.git", + tag: "v1.1.1", + revision: "c723fa0c3fefcc7f89c3847c6cd753cfdaf30486" license "GPL-3.0-only" livecheck do @@ -21,27 +22,33 @@ class Ehco < Formula depends_on "go" => :build + uses_from_macos "netcat" => :test + def install - system "go", "build", *std_go_args, "cmd/ehco/main.go" + ldflags = %W[ + -s -w + -X github.com/Ehco1996/ehco/internal/constant.GitBranch=master + -X github.com/Ehco1996/ehco/internal/constant.GitRevision=#{Utils.git_short_head} + -X github.com/Ehco1996/ehco/internal/constant.BuildTime=#{time.iso8601} + ] + + system "go", "build", *std_go_args(ldflags: ldflags), "cmd/ehco/main.go" end test do - version_info = shell_output("#{bin}/ehco -v") - assert_match "ehco version #{version}", version_info + version_info = shell_output("#{bin}/ehco -v 2>&1") + assert_match "Version=#{version}", version_info # run nc server nc_port = free_port - nc_pid = spawn "nc", "-l", nc_port.to_s + spawn "nc", "-l", nc_port.to_s sleep 1 # run ehco server listen_port = free_port - ehco_pid = spawn bin/"ehco", "-l", "localhost:#{listen_port}", "-r", "localhost:#{nc_port}" + spawn bin/"ehco", "-l", "localhost:#{listen_port}", "-r", "localhost:#{nc_port}" sleep 1 system "nc", "-z", "localhost", listen_port.to_s - ensure - Process.kill("HUP", ehco_pid) - Process.kill("HUP", nc_pid) end end