Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce shallow clone usage #8883

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Library/Homebrew/cmd/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def tap_args
EOS
switch "--full",
description: "Convert a shallow clone to a full clone without untapping. Taps are only cloned as "\
"shallow clones on continuous integration, or if `--shallow` was originally passed."
"shallow clones if `--shallow` was originally passed."
switch "--shallow",
description: "Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration."
switch "--force-auto-update",
Expand All @@ -53,8 +53,6 @@ def tap
else
full_clone = if args.full?
true
elsif !args.shallow?
ENV["CI"].blank?
else
!args.shallow?
end
Expand Down
14 changes: 4 additions & 10 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ git_init_if_necessary() {
fi
git config remote.origin.url "$HOMEBREW_BREW_GIT_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
latest_tag="$(git ls-remote --tags --refs -q origin | tail -n1 | cut -f2)"
git fetch --force origin --shallow-since="$latest_tag"
git fetch --force --tags origin
git remote set-head origin --auto >/dev/null
git reset --hard origin/master
SKIP_FETCH_BREW_REPOSITORY=1
Expand All @@ -60,7 +59,7 @@ git_init_if_necessary() {
fi
git config remote.origin.url "$HOMEBREW_CORE_GIT_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
git fetch --force origin refs/heads/master:refs/remotes/origin/master
git remote set-head origin --auto >/dev/null
git reset --hard origin/master
SKIP_FETCH_CORE_REPOSITORY=1
Expand Down Expand Up @@ -428,12 +427,7 @@ EOS
echo "HOMEBREW_BREW_GIT_REMOTE set: using $HOMEBREW_BREW_GIT_REMOTE for Homebrew/brew Git remote."
git remote set-url origin "$HOMEBREW_BREW_GIT_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
latest_tag="$(git ls-remote --tags --refs -q origin |
cut -d/ -f3 |
sort --numeric-sort --field-separator=. --key=1,1 --key=2,2 --key=3,3 |
tail -n1)"
latest_ref="refs/tags/$latest_tag"
git fetch --force origin --shallow-since="$latest_ref"
git fetch --force --tags origin
fi

if [[ "$HOMEBREW_CORE_DEFAULT_GIT_REMOTE" != "$HOMEBREW_CORE_GIT_REMOTE" ]] &&
Expand All @@ -443,7 +437,7 @@ EOS
echo "HOMEBREW_CORE_GIT_REMOTE set: using $HOMEBREW_CORE_GIT_REMOTE for Homebrew/brew Git remote."
git remote set-url origin "$HOMEBREW_CORE_GIT_REMOTE"
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch --force --depth=1 origin refs/heads/master:refs/remotes/origin/master
git fetch --force origin refs/heads/master:refs/remotes/origin/master
fi

safe_cd "$HOMEBREW_REPOSITORY"
Expand Down
3 changes: 3 additions & 0 deletions Library/Homebrew/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,10 @@ def self.ensure_installed!
safe_system HOMEBREW_BREW_FILE, "tap", instance.name
end

# CoreTap never allows shallow clones (on request from GitHub).
def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil)
raise "Shallow clones are not supported for homebrew-core!" unless full_clone

remote = Homebrew::EnvConfig.core_git_remote
if remote != default_remote
$stderr.puts "HOMEBREW_CORE_GIT_REMOTE set: using #{remote} for Homebrew/core Git remote URL."
Expand Down
2 changes: 1 addition & 1 deletion docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ assumptions, so taps can be cloned from places other than GitHub and
using protocols other than HTTPS, e.g. SSH, git, HTTP, FTP(S), rsync.

* `--full`:
Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones on continuous integration, or if `--shallow` was originally passed.
Convert a shallow clone to a full clone without untapping. Taps are only cloned as shallow clones if `--shallow` was originally passed.
* `--shallow`:
Fetch tap as a shallow clone rather than a full clone. Useful for continuous integration.
* `--force-auto-update`:
Expand Down
2 changes: 1 addition & 1 deletion manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ With \fIURL\fR specified, tap a formula repository from anywhere, using any tran
.
.TP
\fB\-\-full\fR
Convert a shallow clone to a full clone without untapping\. Taps are only cloned as shallow clones on continuous integration, or if \fB\-\-shallow\fR was originally passed\.
Convert a shallow clone to a full clone without untapping\. Taps are only cloned as shallow clones if \fB\-\-shallow\fR was originally passed\.
.
.TP
\fB\-\-shallow\fR
Expand Down