From a92c9eed823a5fd9b1904ab14a1609e3a87a8fea Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 9 Nov 2022 17:29:38 +0000 Subject: [PATCH] style: check more shell scripts. We were missing a few here so add them. Also, fix the changes in `on-create-command.sh` that this catches. --- .devcontainer/on-create-command.sh | 24 +++++++++++++++--------- Library/Homebrew/style.rb | 5 +++-- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.devcontainer/on-create-command.sh b/.devcontainer/on-create-command.sh index b5d3f3d687..63285db4c5 100755 --- a/.devcontainer/on-create-command.sh +++ b/.devcontainer/on-create-command.sh @@ -5,8 +5,9 @@ set -e sudo chmod -R g-w,o-w /home/linuxbrew # everything below is too slow to do unless prebuilding so skip it -CODESPACES_ACTION_NAME="$(cat /workspaces/.codespaces/shared/environment-variables.json | jq -r '.ACTION_NAME')" -if [ "$CODESPACES_ACTION_NAME" != "createPrebuildTemplate" ]; +CODESPACES_ACTION_NAME="$(jq --raw-output '.ACTION_NAME' /workspaces/.codespaces/shared/environment-variables.json)" +if [[ "${CODESPACES_ACTION_NAME}" != "createPrebuildTemplate" ]] +then echo "Skipping slow items, not prebuilding." exit 0 fi @@ -22,18 +23,23 @@ brew cleanup # install some useful development things sudo apt-get update -APT_GET_INSTALL="openssh-server zsh" + +apt_get_install() { + sudo apt-get install -y \ + -o Dpkg::Options::=--force-confdef \ + -o Dpkg::Options::=--force-confnew \ + "$@" +} + +apt_get_install \ + openssh-server \ + zsh # Ubuntu 18.04 doesn't include zsh-autosuggestions if ! grep -q "Ubuntu 18.04" /etc/issue &>/dev/null then - APT_GET_INSTALL="$APT_GET_INSTALL zsh-autosuggestions" + apt_get_install zsh-autosuggestions fi -sudo apt-get install -y \ - -o Dpkg::Options::=--force-confdef \ - -o Dpkg::Options::=--force-confnew \ - $APT_GET_INSTALL - # Start the SSH server so that `gh cs ssh` works. sudo service ssh start diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index e3a7c763b7..6beacb720b 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -262,12 +262,13 @@ module Homebrew HOMEBREW_BREW_FILE, HOMEBREW_REPOSITORY/"completions/bash/brew", HOMEBREW_REPOSITORY/"Dockerfile", - *HOMEBREW_LIBRARY.glob("Homebrew/*.sh"), + *HOMEBREW_REPOSITORY.glob(".devcontainer/**/*.sh"), + *HOMEBREW_LIBRARY.glob("Homebrew/**/*.sh").reject { |path| path.to_s.include?("/vendor/") }, *HOMEBREW_LIBRARY.glob("Homebrew/shims/**/*").map(&:realpath).uniq .reject(&:directory?) .reject { |path| path.basename.to_s == "cc" } .select do |path| - %r{^#! ?/bin/(?:ba)?sh( |$)}.match?(path.read(13)) || path.extname == ".sh" + %r{^#! ?/bin/(?:ba)?sh( |$)}.match?(path.read(13)) end, *HOMEBREW_LIBRARY.glob("Homebrew/{dev-,}cmd/*.sh"), *HOMEBREW_LIBRARY.glob("Homebrew/{cask/,}utils/*.sh"),