mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
script: various (#48662)
This commit is contained in:
@@ -15,6 +15,7 @@ shopt -s extglob
|
||||
CYAN='\033[0;36m'
|
||||
MAGENTA='\033[1;35m'
|
||||
RED='\033[1;31m'
|
||||
YELLOW='\033[0;33m'
|
||||
NC='\033[0m' # no color
|
||||
|
||||
# log command before running and add a blank line
|
||||
@@ -30,8 +31,13 @@ ohai () {
|
||||
echo -e "${MAGENTA}>>>${NC} $*"
|
||||
}
|
||||
|
||||
onoe () {
|
||||
echo -e "${YELLOW}>>> $* ${NC}"
|
||||
exit 0
|
||||
}
|
||||
|
||||
odie () {
|
||||
echo -e "${RED}!!!${NC} $*"
|
||||
echo -e "${RED}!!! $* !!!${NC}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
+33
-32
@@ -23,43 +23,44 @@ for check in "${checks[@]}"; do
|
||||
"${check}" > "${HOME}/cask-checks/before/${check}"
|
||||
done
|
||||
|
||||
modified_ruby_files=($(git diff --name-only --diff-filter=AMR "${TRAVIS_COMMIT_RANGE}" -- *.rb))
|
||||
|
||||
for file in "${modified_ruby_files[@]}"; do
|
||||
[[ "${file}" == 'Casks/'* ]] && modified_casks+=("${file}") || casks_wrong_dir+=("${file}")
|
||||
done
|
||||
modified_casks=($(git diff --name-only --diff-filter=AMR "${TRAVIS_COMMIT_RANGE}" -- Casks/*.rb))
|
||||
|
||||
run export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
|
||||
if [[ ${#casks_wrong_dir[@]} -gt 0 ]]; then
|
||||
odie "Casks added outside Casks directory: ${casks_wrong_dir[*]}"
|
||||
elif [[ ${#modified_casks[@]} -gt 0 ]]; then
|
||||
if [[ ${#modified_casks[@]} -le 3 ]]; then
|
||||
for cask in "${modified_casks[@]}"; do
|
||||
if brew cask _stanza gpg "${cask}" &> /dev/null; then
|
||||
run brew outdated gnupg || run brew upgrade gnupg
|
||||
fi
|
||||
done
|
||||
if [[ ${#modified_casks[@]} -eq 0 ]]; then
|
||||
onoe 'No Casks modified, skipping'
|
||||
fi
|
||||
|
||||
run brew cask style "${modified_casks[@]}"
|
||||
|
||||
if [[ "${TRAVIS_REPO_SLUG}" != 'Homebrew/homebrew-cask-fonts' ]]; then
|
||||
if [[ ${#modified_casks[@]} -gt 1 ]]; then
|
||||
run brew cask audit "${modified_casks[@]}"
|
||||
odie "More than 1 Cask modified, didn't check Cask checksums or URLs"
|
||||
fi
|
||||
run brew cask _audit_modified_casks "${TRAVIS_COMMIT_RANGE}"
|
||||
run brew cask style "${modified_casks[@]}"
|
||||
if [[ ${#modified_casks[@]} -le 3 ]]; then
|
||||
if /usr/bin/grep "depends_on cask:" "${modified_casks[@]}" > /dev/null; then
|
||||
run brew tap homebrew/bundle
|
||||
run brew bundle dump --file="${HOME}/Brewfile"
|
||||
|
||||
# check if gnupg is up to date for _audit_modified_casks
|
||||
for cask in "${modified_casks[@]}"; do
|
||||
if brew cask _stanza gpg "${cask}" &> /dev/null; then
|
||||
run brew outdated gnupg || run brew upgrade gnupg
|
||||
fi
|
||||
for cask in "${modified_casks[@]}"; do
|
||||
run brew cask reinstall --verbose "${cask}"
|
||||
run brew cask uninstall --verbose "${cask}"
|
||||
done
|
||||
if [[ -f "${HOME}/Brewfile" ]]; then
|
||||
run brew bundle cleanup --force --file="${HOME}/Brewfile"
|
||||
fi
|
||||
else
|
||||
ohai 'More than 3 Casks modified, skipping install'
|
||||
fi
|
||||
else
|
||||
ohai 'No Casks modified, skipping'
|
||||
done
|
||||
fi
|
||||
|
||||
run brew cask _audit_modified_casks "${TRAVIS_COMMIT_RANGE}"
|
||||
|
||||
if /usr/bin/grep --quiet "depends_on cask:" "${modified_casks[@]}"; then
|
||||
run brew tap homebrew/bundle
|
||||
run brew bundle dump --file="${HOME}/Brewfile"
|
||||
fi
|
||||
|
||||
for cask in "${modified_casks[@]}"; do
|
||||
run brew cask reinstall --verbose "${cask}"
|
||||
run brew cask uninstall --verbose "${cask}"
|
||||
done
|
||||
|
||||
if [[ -f "${HOME}/Brewfile" ]]; then
|
||||
run brew bundle cleanup --force --file="${HOME}/Brewfile"
|
||||
fi
|
||||
|
||||
sleep 5 # Rerunning the checks too soon can result in false positives
|
||||
|
||||
@@ -34,11 +34,6 @@ function copy_templates_and_ci {
|
||||
rsync --archive --delete "${main_repo_dir}"/{.editorconfig,.gitattributes,.github,.gitignore,.travis.yml,ci,CODE_OF_CONDUCT.md} '.'
|
||||
rm '.github/ISSUE_TEMPLATE/02_feature_request.md' # Feature requests only make sense in the main repo
|
||||
/usr/bin/sed -i '' -E "s:homebrew-cask/(pulls|issues):${repo_name}/\1:" '.github/PULL_REQUEST_TEMPLATE.md' # PULL_REQUEST_TEMPLATE has repo-specific links
|
||||
|
||||
# increase script.sh install cap for fonts repo
|
||||
if [[ "${repo_name}" == 'homebrew-cask-fonts' ]]; then
|
||||
/usr/bin/sed -i '' -e 's:-le 3:-le 15:' -e 's:than 3 Casks:than 15 Casks:' 'ci/travis/script.sh'
|
||||
fi
|
||||
}
|
||||
|
||||
function push_changes {
|
||||
|
||||
Reference in New Issue
Block a user