class Gitup < Formula desc "Update multiple git repositories at once" homepage "https://github.com/earwig/git-repo-updater" url "https://github.com/earwig/git-repo-updater.git", :revision => "bf66406c10d3e7654ca3f56f4ec6b57bcc068fea", :tag => "v0.4.1" bottle do cellar :any_skip_relocation sha256 "48097ac6e344cc404757a244dfc853558027f5fedca02d0e1b1abb2ae64f5577" => :mojave sha256 "8a11d7864ef368045ba5ebed1580fe3a22f4e04b24f4f24c9678eefbf186afc7" => :high_sierra sha256 "8a11d7864ef368045ba5ebed1580fe3a22f4e04b24f4f24c9678eefbf186afc7" => :sierra sha256 "c1659d82d045517de16860042a53360b5ce061c8d13e57b8ea15db624ad7289f" => :el_capitan end depends_on "python@2" resource "colorama" do url "https://files.pythonhosted.org/packages/source/c/colorama/colorama-0.3.9.tar.gz" sha256 "48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1" end resource "smmap2" do url "https://files.pythonhosted.org/packages/source/s/smmap2/smmap2-2.0.3.tar.gz" sha256 "c7530db63f15f09f8251094b22091298e82bf6c699a6b8344aaaef3f2e1276c3" end resource "gitdb2" do url "https://files.pythonhosted.org/packages/source/g/gitdb2/gitdb2-2.0.3.tar.gz" sha256 "b60e29d4533e5e25bb50b7678bbc187c8f6bcff1344b4f293b2ba55c85795f09" end resource "GitPython" do url "https://files.pythonhosted.org/packages/source/G/GitPython/GitPython-2.1.8.tar.gz" sha256 "ad61bc25deadb535b047684d06f3654c001d9415e1971e51c9c20f5b510076e9" end def install ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages" %w[colorama smmap2 gitdb2 GitPython].each do |r| resource(r).stage do system "python", *Language::Python.setup_install_args(libexec/"vendor") end end ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python2.7/site-packages" system "python", *Language::Python.setup_install_args(libexec) bin.install Dir[libexec/"bin/*"] bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) end test do def prepare_repo(uri, local_head) system "git", "init" system "git", "remote", "add", "origin", uri system "git", "fetch", "origin" system "git", "checkout", local_head system "git", "reset", "--hard" system "git", "checkout", "-b", "master" system "git", "branch", "--set-upstream-to=origin/master", "master" end first_head_start = "f47ab45abdbc77e518776e5dc44f515721c523ae" mkdir "first" do prepare_repo("https://github.com/pr0d1r2/homebrew-contrib.git", first_head_start) end second_head_start = "f863d5ca9e39e524e8c222428e14625a5053ed2b" mkdir "second" do prepare_repo("https://github.com/pr0d1r2/homebrew-cask-games.git", second_head_start) end system bin/"gitup", "first", "second" first_head = `cd first ; git rev-parse HEAD`.split.first assert_not_equal first_head, first_head_start second_head = `cd second ; git rev-parse HEAD`.split.first assert_not_equal second_head, second_head_start third_head_start = "f47ab45abdbc77e518776e5dc44f515721c523ae" mkdir "third" do prepare_repo("https://github.com/pr0d1r2/homebrew-contrib.git", third_head_start) end system bin/"gitup", "--add", "third" system bin/"gitup" third_head = `cd third ; git rev-parse HEAD`.split.first assert_not_equal third_head, third_head_start assert_match %r{#{Dir.pwd}/third}, `#{bin}/gitup --list`.strip system bin/"gitup", "--delete", "#{Dir.pwd}/third" end end