vitorgalvao / tiny-scripts

Collection of small scripts
The Unlicense
309 stars 53 forks source link

[FR]Automatic unshallow in cask-repair #59

Closed yurikoles closed 7 years ago

yurikoles commented 7 years ago

Brew and taps clones are shallow by default. Please implement feature that will detect and automatically unshallow the clone, thanks. Also it may be useful to tap it with --full flag. I'm using following script by myself

# !bash
if hash brew 2>/dev/null; then
    cd `brew --prefix`/Homebrew/Library/Taps/
    for d in *; do 
        cd $d
        echo "unshallowing all in $d"
        for f in *; do
            cd $f
            echo "unshallowing $f"
            git fetch --unshallow
            git checkout master -f
            cd ..
        done
        cd ..
    done
fi
vitorgalvao commented 7 years ago

Why? I need a reason. What isn’t working?

yurikoles commented 7 years ago

It fails to push with error like "shallow updates are not allowed", sorry I can't reproduce it now, because I have unshallowed all my repos.

vitorgalvao commented 7 years ago

I haven’t encountered this issue and haven’t got any other reports, so it may be something with your setup.

Will keep it in mind, though, and if more people encounter this, I’ll make the script use brew tap --full when first tapping the repos.

yurikoles commented 7 years ago

It's reproducing. You can imagine how tired I was to repeat unshallowing after every (re-)install of brew so I wrote a script to automate it.

1 ✗ yurikoles@home  ~ $ rm -rf /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask/
0 ✓ yurikoles@home  ~ $ brew tap caskroom/cask
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
fdroidserver        mapnik              sdl2_image          webp (installed)
gd (installed)      mldonkey            sdl_image
gnuplot             mscgen              webkitgtk

==> Tapping caskroom/cask
Cloning into '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask'...
remote: Counting objects: 3665, done.
remote: Compressing objects: 100% (3649/3649), done.
remote: Total 3665 (delta 36), reused 298 (delta 12), pack-reused 0
Receiving objects: 100% (3665/3665), 1.22 MiB | 1.38 MiB/s, done.
Resolving deltas: 100% (36/36), done.
Tapped 0 formulae (3,674 files, 3.8M)
0 ✓ yurikoles@home  ~ $ cask-repair deadbeef
Updating taps… Already up-to-date.
A `cask-repair` remote does not exist. Creating it now…
--------------------------------------------------------------------------------
cask 'deadbeef' do
  version '0.7.2'
  sha256 '09f588fc548f5faf1b58f07aafd0d65f5df1f8e00c143e80ddd879f02a7d33c0'

  url 'https://downloads.sourceforge.net/deadbeef/travis/osx/master/deadbeef-devel-osx-x86_64.zip'
  appcast 'https://sourceforge.net/projects/deadbeef/rss?path=/travis/osx/master',
          checkpoint: 'df2ceb0eb07b78a7b1a4c1ebdc388ce157ac9eb1ca97792e66bf395bf4922844'
  name 'DeaDBeeF'
  homepage 'http://deadbeef.sourceforge.net/'

  app 'deadbeef.app'
end
--------------------------------------------------------------------------------
Type the new version (or leave blank to use current one, or use `s` to skip)
> 
Paste the new URL (or leave blank to use the current one)
> 
==> Downloading external files for Cask ./deadbeef.rb
==> Downloading https://downloads.sourceforge.net/deadbeef/travis/osx/master/dea
######################################################################## 100,0%
==> No checksum defined for Cask deadbeef, skipping verification
==> Success! Downloaded to -> /Users/yurikoles/Library/Caches/Homebrew/Cask/dead
diff --git a/Casks/deadbeef.rb b/Casks/deadbeef.rb
index b67a17d..dba6a26 100644
--- a/Casks/deadbeef.rb
+++ b/Casks/deadbeef.rb
@@ -4,7 +4,7 @@ cask 'deadbeef' do

   url 'https://downloads.sourceforge.net/deadbeef/travis/osx/master/deadbeef-devel-osx-x86_64.zip'
   appcast 'https://sourceforge.net/projects/deadbeef/rss?path=/travis/osx/master',
-          checkpoint: 'df2ceb0eb07b78a7b1a4c1ebdc388ce157ac9eb1ca97792e66bf395bf4922844'
+          checkpoint: '6a56a0934f2bc58cadbafaeeef20f7e4605b85d4af298dfe811173ff773f19f1'
   name 'DeaDBeeF'
   homepage 'http://deadbeef.sourceforge.net/'

--------------------------------------------------------------------------------
Is everything correct? ([y]es / [n]o / [e]dit) y
Submitting…
To github.com:yurikoles/homebrew-cask
 ! [remote rejected] cask-repair_update-deadbeef -> cask-repair_update-deadbeef (shallow update not allowed)
error: failed to push some refs to 'git@github.com:yurikoles/homebrew-cask'
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"
Error creating pull request: Unprocessable Entity (HTTP 422)
Invalid value for "head"

There was an error submitting the pull request. Please open a bug report on the repo for this script.
vitorgalvao commented 7 years ago

@yurikoles Yes, I believe that it happens to you, but since you’ve already fixed it for yourself and I see no other users (or myself) with the same issue, I’d rather not touch it for now.

mskblackbelt commented 7 years ago

I just ran into this issue while trying to update PDFpenPro… git fetch --unshallow in the Cask folder took care of the issue. Would be nice if this could be included as part of the cask-repair script, reduces the barrier to entry for inexperienced users.

yurikoles commented 7 years ago

@vitorgalvao according to official doc brew tap makes shallow clones by default.

vitorgalvao commented 7 years ago

Here’s the problem: I never encountered this issue, as haven’t the majority of users of this tool.

I’m willing to fix it for good, but I need someone willing to run a few commands and give me the results. Is there anyone that is able to reproduce this error consistently and on demand?

yurikoles commented 7 years ago

@vitorgalvao I had reproduced this error on every copy of macOS that I had my hands on, so I'm volunteering.

vitorgalvao commented 7 years ago

@yurikoles Thank you. I’ll basically give you a few different versions of cask-repair with different tweaks, to first understand the error better. With that, I’ll be able to fix it more accurately. I ask that you grab the version and use it to submit casks, and post the output.

First one.

yurikoles commented 7 years ago

It reports Unprocessable Entity (HTTP 422). I think we just found the reason for this error message :)

cask-repair epic-games-launcher ``` $ cask-repair epic-games-launcher Updating taps… Already up-to-date. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- cask 'epic-games-launcher' do version '2.12.14-3176191' sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" name 'Epic Games Launcher' homepage 'https://www.unrealengine.com/what-is-unreal-engine-4' app 'Epic Games Launcher.app' zap delete: '~/Library/Caches/com.epicgames.EpicGamesLauncher' end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Type the new version (or leave blank to use current one, or use `s` to skip) > 2.12.24-3321064 ==> Downloading external files for Cask ./epic-games-launcher.rb ==> Downloading https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-2.12.24-3321064.dmg ######################################################################## 100,0% ==> No checksum defined for Cask epic-games-launcher, skipping verification ==> Success! Downloaded to -> /Users/yurikoles/Library/Caches/Homebrew/Cask/epic-games-launcher--2.12.24-3321064.dmg diff --git a/Casks/epic-games-launcher.rb b/Casks/epic-games-launcher.rb index c1c0ab4..2219303 100644 --- a/Casks/epic-games-launcher.rb +++ b/Casks/epic-games-launcher.rb @@ -1,6 +1,6 @@ cask 'epic-games-launcher' do - version '2.12.14-3176191' - sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' + version '2.12.24-3321064' + sha256 'b1e37a5ff042fb5e13cd904d71acb14496bd65036612a726ff3b509947779c1d' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Is everything correct? ([y]es / [n]o / [e]dit) y Submitting… 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 [cask-repair_update-epic-games-launcher c90b965] Update epic-games-launcher to 2.12.24-3321064 1 file changed, 2 insertions(+), 2 deletions(-) 2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 Counting objects: 3698, done. Delta compression using up to 4 threads. Compressing objects: 100% (3658/3658), done. Writing objects: 100% (3698/3698), 1.23 MiB | 0 bytes/s, done. Total 3698 (delta 39), reused 3691 (delta 36) remote: Resolving deltas: 100% (39/39), done. To github.com:yurikoles/homebrew-cask ! [remote rejected] cask-repair_update-epic-games-launcher -> cask-repair_update-epic-games-launcher (shallow update not allowed) error: failed to push some refs to 'git@github.com:yurikoles/homebrew-cask' 3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333 Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 There was an error submitting the pull request. Please open a bug report on the repo for this script. ```
vitorgalvao commented 7 years ago

Second one.

yurikoles commented 7 years ago
cask-repair epic-games-launcher ``` $ cask-repair epic-games-launcher Updating taps… Updated 2 taps (caskroom/cask, homebrew/core). ==> Updated Formulae alot awscli doitlive kubernetes-cli mikutter monotone sourcery vim aws-sdk-cpp botan jid lxc monit softhsm vala (installed) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- cask 'epic-games-launcher' do version '2.12.14-3176191' sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" name 'Epic Games Launcher' homepage 'https://www.unrealengine.com/what-is-unreal-engine-4' app 'Epic Games Launcher.app' zap delete: '~/Library/Caches/com.epicgames.EpicGamesLauncher' end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Type the new version (or leave blank to use current one, or use `s` to skip) > 2.12.24-3321064 ==> Downloading external files for Cask ./epic-games-launcher.rb ==> Downloading https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-2.12.24-3321064.dmg ######################################################################## 100,0% ==> No checksum defined for Cask epic-games-launcher, skipping verification ==> Success! Downloaded to -> /Users/yurikoles/Library/Caches/Homebrew/Cask/epic-games-launcher--2.12.24-3321064.dmg diff --git a/Casks/epic-games-launcher.rb b/Casks/epic-games-launcher.rb index c1c0ab4c3..221930375 100644 --- a/Casks/epic-games-launcher.rb +++ b/Casks/epic-games-launcher.rb @@ -1,6 +1,6 @@ cask 'epic-games-launcher' do - version '2.12.14-3176191' - sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' + version '2.12.24-3321064' + sha256 'b1e37a5ff042fb5e13cd904d71acb14496bd65036612a726ff3b509947779c1d' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Is everything correct? ([y]es / [n]o / [e]dit) y Submitting… [cask-repair_update-epic-games-launcher 14a1c97e5] Update epic-games-launcher to 2.12.24-3321064 1 file changed, 2 insertions(+), 2 deletions(-) ######################################################################################################################################################################################## PUSHING Counting objects: 3718, done. Delta compression using up to 4 threads. Compressing objects: 100% (3666/3666), done. Writing objects: 100% (3718/3718), 1.23 MiB | 0 bytes/s, done. Total 3718 (delta 53), reused 3709 (delta 48) remote: Resolving deltas: 100% (53/53), done. To github.com:yurikoles/homebrew-cask ! [remote rejected] cask-repair_update-epic-games-launcher -> cask-repair_update-epic-games-launcher (shallow update not allowed) error: failed to push some refs to 'git@github.com:yurikoles/homebrew-cask' ERROR CODE: 1 ######################################################################################################################################################################################## Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 There was an error submitting the pull request. Please open a bug report on the repo for this script. ```
vitorgalvao commented 7 years ago

Third.

yurikoles commented 7 years ago
```$ cask-repair -b -v 2.12.24-3321064 epic-games-launcher Updating taps… Already up-to-date. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- cask 'epic-games-launcher' do version '2.12.14-3176191' sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" name 'Epic Games Launcher' homepage 'https://www.unrealengine.com/what-is-unreal-engine-4' app 'Epic Games Launcher.app' zap delete: '~/Library/Caches/com.epicgames.EpicGamesLauncher' end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ==> Downloading external files for Cask ./epic-games-launcher.rb ==> Downloading https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-2.12.24-3321064.dmg ######################################################################## 100,0% ==> No checksum defined for Cask epic-games-launcher, skipping verification ==> Success! Downloaded to -> /Users/yurikoles/Library/Caches/Homebrew/Cask/epic-games-launcher--2.12.24-3321064.dmg diff --git a/Casks/epic-games-launcher.rb b/Casks/epic-games-launcher.rb index c1c0ab4c3..221930375 100644 --- a/Casks/epic-games-launcher.rb +++ b/Casks/epic-games-launcher.rb @@ -1,6 +1,6 @@ cask 'epic-games-launcher' do - version '2.12.14-3176191' - sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' + version '2.12.24-3321064' + sha256 'b1e37a5ff042fb5e13cd904d71acb14496bd65036612a726ff3b509947779c1d' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Submitting… [cask-repair_update-epic-games-launcher 741a5f6b1] Update epic-games-launcher to 2.12.24-3321064 1 file changed, 2 insertions(+), 2 deletions(-) ######################################################################################################################################################################################## PUSHING ECHOING RESULTS To github.com:yurikoles/homebrew-cask ! [remote rejected] cask-repair_update-epic-games-launcher -> cask-repair_update-epic-games-launcher (shallow update not allowed) error: failed to push some refs to 'git@github.com:yurikoles/homebrew-cask' ######################################################################################################################################################################################## Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" Error creating pull request: Unprocessable Entity (HTTP 422) Invalid value for "head" ######################################################################################################################################################################################## There was an error submitting the pull request. Please open a bug report on the repo for this script. ```
vitorgalvao commented 7 years ago

Fourth.

yurikoles commented 7 years ago

Last line is strange

``` $ cask-repair -b -v 2.12.24-3321064 epic-games-launcher Updating taps… Updated 1 tap (caskroom/cask). No changes to formulae. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- cask 'epic-games-launcher' do version '2.12.14-3176191' sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" name 'Epic Games Launcher' homepage 'https://www.unrealengine.com/what-is-unreal-engine-4' app 'Epic Games Launcher.app' zap delete: '~/Library/Caches/com.epicgames.EpicGamesLauncher' end ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ==> Downloading external files for Cask ./epic-games-launcher.rb ==> Downloading https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-2.12.24-3321064.dmg ######################################################################## 100,0% ==> No checksum defined for Cask epic-games-launcher, skipping verification ==> Success! Downloaded to -> /Users/yurikoles/Library/Caches/Homebrew/Cask/epic-games-launcher--2.12.24-3321064.dmg diff --git a/Casks/epic-games-launcher.rb b/Casks/epic-games-launcher.rb index c1c0ab4c3..221930375 100644 --- a/Casks/epic-games-launcher.rb +++ b/Casks/epic-games-launcher.rb @@ -1,6 +1,6 @@ cask 'epic-games-launcher' do - version '2.12.14-3176191' - sha256 '35d3a60287a37a1d41468ecb560ef85b52b08ca6d1ff7e8bfc370450e84ede31' + version '2.12.24-3321064' + sha256 'b1e37a5ff042fb5e13cd904d71acb14496bd65036612a726ff3b509947779c1d' # epicgames.com was verified as official when first introduced to the cask url "https://download.epicgames.com/Builds/UnrealEngineLauncher/Installers/EpicGamesLauncher-#{version}.dmg" ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Submitting… [cask-repair_update-epic-games-launcher a4cf796f1] Update epic-games-launcher to 2.12.24-3321064 1 file changed, 2 insertions(+), 2 deletions(-) ######################################################################################################################################################################################## PUSHING ERROR DUE TO SHALLOW REPO, UNSHALLOWING AND TRYING AGAIN Updating Homebrew... ==> Unshallowing caskroom/cask remote: Counting objects: 62008, done. remote: Compressing objects: 100% (18869/18869), done. remote: Total 62008 (delta 47226), reused 57769 (delta 43040), pack-reused 0 Receiving objects: 100% (62008/62008), 19.78 MiB | 2.09 MiB/s, done. Resolving deltas: 100% (47226/47226), completed with 4515 local objects. ######################################################################################################################################################################################## ######################################################################################################################################################################################## You can upgrade the cask right now from your personal branch: brew cask reinstall https://raw.githubusercontent.com/yurikoles/homebrew-cask/cask-repair_update-epic-games-launcher/Casks/epic-games-launcher.rb Submitted (https://github.com/caskroom/homebrew-cask/pull/30709) error: Cannot delete branch 'master' checked out at '/usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask' ```
vitorgalvao commented 7 years ago

Last line is strange.

Indeed. For now, I’ll assume it was due to the previous commands not cleaning correctly and leaving you at the master branch.

Just released a new cask-repair version. The unshallow repos bug should be squashed. Thank you for the help and fast responses, @yurikoles.

yurikoles commented 7 years ago

@vitorgalvao I had re-run cask-repair on this cask after launching it with -d flag, and this message has gone.