From b3ef9ccb8a4ab5c853c1bf683ebc9e16670f0013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 27 Jun 2017 14:21:14 +0200 Subject: [PATCH 1/3] Fix `bump-formula-pr` when working with a shallow git clone Creating a fork and pushing to it doesn't work when the repository in question is a shallow clone. By default, Homebrew clones all taps in shallow mode unless `--full` was passed or $HOMEBREW_DEVELOPER was set. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 586eec47cf..d65516b780 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -287,6 +287,7 @@ module Homebrew formula.path.parent.cd do branch = "#{formula.name}-#{new_formula_version}" if ARGV.dry_run? + ohai "git fetch --unshallow origin" ohai "git checkout --no-track -b #{branch} origin/master" ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}" ohai "hub fork --no-remote" @@ -296,6 +297,7 @@ module Homebrew ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'" ohai "git checkout -" else + safe_system "git", "fetch", "--unshallow", "origin" safe_system "git", "checkout", "--no-track", "-b", branch, "origin/master" safe_system "git", "commit", "--no-edit", "--verbose", "--message=#{formula.name} #{new_formula_version}#{devel_message}", From 3701b11e42a93ee9c1bb94f326ee186d4416501c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 27 Jun 2017 23:45:57 +0200 Subject: [PATCH 2/3] Fix unshallowing taps in `bump-formula-pr` Never try to unhshallow full clones. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index d65516b780..74a676d9a6 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -286,8 +286,11 @@ module Homebrew formula.path.parent.cd do branch = "#{formula.name}-#{new_formula_version}" + git_dir = Utils.popen_read("git rev-parse --git-dir") + shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") + if ARGV.dry_run? - ohai "git fetch --unshallow origin" + ohai "git fetch --unshallow origin" if shallow ohai "git checkout --no-track -b #{branch} origin/master" ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}" ohai "hub fork --no-remote" @@ -297,7 +300,7 @@ module Homebrew ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'" ohai "git checkout -" else - safe_system "git", "fetch", "--unshallow", "origin" + safe_system "git", "fetch", "--unshallow", "origin" if shallow safe_system "git", "checkout", "--no-track", "-b", branch, "origin/master" safe_system "git", "commit", "--no-edit", "--verbose", "--message=#{formula.name} #{new_formula_version}#{devel_message}", From f8ec2332a214ac9a59a91a49f6b0ef72eac5ff6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 29 Jun 2017 13:28:55 +0200 Subject: [PATCH 3/3] Strip trailing newline --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 74a676d9a6..1c56749a34 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -286,7 +286,7 @@ module Homebrew formula.path.parent.cd do branch = "#{formula.name}-#{new_formula_version}" - git_dir = Utils.popen_read("git rev-parse --git-dir") + git_dir = Utils.popen_read("git rev-parse --git-dir").chomp shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") if ARGV.dry_run?