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

Check for both shallow clones at the same time. #9501

Merged
merged 6 commits into from
Dec 14, 2020
Merged

Check for both shallow clones at the same time. #9501

merged 6 commits into from
Dec 14, 2020

Conversation

rgant
Copy link
Contributor

@rgant rgant commented Dec 10, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

I find it confusing that the first time you fail because of an shallow clone issue it only tells you about one of the shallow clones. Since the second one is very similarly named, for example #9420.

This is a terrible way to do it, but since I am completely unfamiliar with how brew is constructed it is a straightforward example of the way I think it should work.

@rgant
Copy link
Contributor Author

rgant commented Dec 10, 2020

euphorbus:~$ touch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/shallow
euphorbus:~$ touch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/shallow
euphorbus:~$ subl /usr/local/Homebrew/Library/Homebrew/cmd/update.sh 
euphorbus:~$ brew update
Error:   homebrew-core is a shallow clone.
  homebrew-cask is a shallow clone.
  To `brew update`, first run:
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
  This restriction has been made on GitHub's request because updating shallow
  clones is an extremely expensive operation due to the tree layout and traffic of
  Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
  automatically to avoid repeatedly performing an expensive unshallow operation in
  CI systems (which should instead be fixed to not use shallow clones). Sorry for
  the inconvenience!
euphorbus:~$ rm /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/shallow
remove /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/shallow? y
euphorbus:~$ brew update
Error:   
  homebrew-cask is a shallow clone.
  To `brew update`, first run:
    
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
  This restriction has been made on GitHub's request because updating shallow
  clones is an extremely expensive operation due to the tree layout and traffic of
  Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
  automatically to avoid repeatedly performing an expensive unshallow operation in
  CI systems (which should instead be fixed to not use shallow clones). Sorry for
  the inconvenience!
euphorbus:~$ rm /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/shallow
remove /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/shallow? y
euphorbus:~$ brew update
Updated 2 taps (homebrew/core and homebrew/cask).

@maxim-belkin
Copy link
Member

I don't like empty lines in the output. The following produces a better result (suppresses empty lines) but I can't say that I'm a big fan of how this code looks so let's see what other maintainers think about it.

  [[ -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core/.git/shallow" ]] && SHALLOW_CORE=1
  [[ -f "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-cask/.git/shallow" ]] && SHALLOW_CASK=1

  if [[ -n $SHALLOW_CORE || -n $SHALLOW_CASK ]]
  then
    odie <<EOS
${SHALLOW_CORE:+homebrew-core is a shallow clone.${SHALLOW_CASK:+
       }}${SHALLOW_CASK:+\
homebrew-cask is a shallow clone.}
To \`brew update\`, first run:
  ${SHALLOW_CORE:+git -C "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-core" fetch --unshallow${SHALLOW_CASK:+
}}${SHALLOW_CASK:+\
  git -C "$HOMEBREW_LIBRARY/Taps/homebrew/homebrew-cask" fetch --unshallow}
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
EOS
  fi

Library/Homebrew/cmd/update.sh Outdated Show resolved Hide resolved
Library/Homebrew/cmd/update.sh Outdated Show resolved Hide resolved
@MikeMcQuaid
Copy link
Member

Thanks for opening a PR @rgant ❤️

I don't like empty lines in the output

Agreed 👍🏻

@rgant
Copy link
Contributor Author

rgant commented Dec 11, 2020

I would imagine that 99.999 times out of 100 it would be both repos are shallow or neither are (once this message is the default instructing you to fix both at the same time). So making it look nice when there is only one feels like polishing an edge case. But if you want to do it then I've added my way of doing that.

euphorbus:~$ brew update
Error:   
    homebrew-cask is a shallow clone.
  To `brew update`, first run:
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
  This restriction has been made on GitHub's request because updating shallow
  clones is an extremely expensive operation due to the tree layout and traffic of
  Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
  automatically to avoid repeatedly performing an expensive unshallow operation in
  CI systems (which should instead be fixed to not use shallow clones). Sorry for
  the inconvenience!
euphorbus:~$ touch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/.git/shallow
euphorbus:~$ brew update
Error:   
    homebrew-core is a shallow clone.
    homebrew-cask is a shallow clone.
  To `brew update`, first run:
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
  This restriction has been made on GitHub's request because updating shallow
  clones is an extremely expensive operation due to the tree layout and traffic of
  Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
  automatically to avoid repeatedly performing an expensive unshallow operation in
  CI systems (which should instead be fixed to not use shallow clones). Sorry for
  the inconvenience!
euphorbus:~$ rm /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/shallow
remove /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/.git/shallow? y
euphorbus:~$ brew update
Error:   
    homebrew-core is a shallow clone.
  To `brew update`, first run:
    git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
  This restriction has been made on GitHub's request because updating shallow
  clones is an extremely expensive operation due to the tree layout and traffic of
  Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
  automatically to avoid repeatedly performing an expensive unshallow operation in
  CI systems (which should instead be fixed to not use shallow clones). Sorry for
  the inconvenience!

Co-authored-by: Maxim Belkin <maxim.belkin@gmail.com>
Copy link
Member

@maxim-belkin maxim-belkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @rgant! Looks great!

@MikeMcQuaid MikeMcQuaid merged commit 77561fc into Homebrew:master Dec 14, 2020
@MikeMcQuaid
Copy link
Member

Thanks so much for your first contribution! Without people like you submitting PRs we couldn't run this project. You rock, @rgant!

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 14, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants