diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index d4a2c6f3fef6eb..7c745acf568202 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -29,17 +29,24 @@ jobs: checkout: '' # false (ref: https://github.com/actions/runner/issues/2238) # Run this step first to make sure auto-style commits are pushed - - name: ${{ github.ref == 'refs/heads/master' && 'Auto-correct' || 'Check for' }} code styles + - name: Auto-correct code styles run: | set -x - ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" "$PUSH_REF" + ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" refs/heads/master env: - EMAIL: svn-admin@ruby-lang.org + GITHUB_OLD_SHA: ${{ github.event.before }} + GITHUB_NEW_SHA: ${{ github.event.after }} GIT_AUTHOR_NAME: git GIT_COMMITTER_NAME: git + EMAIL: svn-admin@ruby-lang.org + if: ${{ github.repository == 'ruby/ruby' && github.ref == 'refs/heads/master' && github.event_name == 'push' }} + - name: Check for code styles + run: | + set -x + ruby tool/auto-style.rb "$GITHUB_OLD_SHA" "$GITHUB_NEW_SHA" + env: GITHUB_OLD_SHA: ${{ github.event.pull_request.base.sha }} GITHUB_NEW_SHA: ${{ github.event.pull_request.merge_commit_sha }} - PUSH_REF: ${{ github.ref == 'refs/heads/master' && github.ref || '' }} if: ${{ github.repository == 'ruby/ruby' && startsWith(github.event_name, 'pull') }} - name: Check if C-sources are US-ASCII diff --git a/libexec/erb b/libexec/erb index a1fb7457585d9b..de7d5888c346e8 100755 --- a/libexec/erb +++ b/libexec/erb @@ -132,7 +132,7 @@ Filepaths: If no filepaths are given, the sole input is the standard input. -See details and examples at https://docs.ruby-lang.org/en/master/erb_executable_md.html +See details and examples at https://docs.ruby-lang.org/en/master/erb_executable_md.html EOU exit 1 end diff --git a/tool/auto-style.rb b/tool/auto-style.rb index 259ed377bc7036..3b93c8c3179291 100755 --- a/tool/auto-style.rb +++ b/tool/auto-style.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # Usage: -# auto-style.rb [oldrev] [newrev] [pushref] +# auto-style.rb oldrev newrev [pushref] require 'shellwords' require 'tmpdir' @@ -71,9 +71,9 @@ def diff private def git(*args, **opts) - cmd = ['git', *args].shelljoin - puts "+ #{cmd}" - ret = with_clean_env { system('git', *args, **opts) } + cmd = ['git', *args] + puts "+ #{cmd.shelljoin}" + ret = with_clean_env { system(*cmd, **opts) } unless ret or opts[:err] abort "Failed to run: #{cmd}" end @@ -251,7 +251,7 @@ def adjust_styles(files) _, *updated_files = ARGV git = Git.new(nil, nil) else - unless dry_run = pushref.empty? + unless dry_run = pushref.nil? branch = IO.popen(['git', 'rev-parse', '--symbolic', '--abbrev-ref', pushref], &:read).strip end git = Git.new(oldrev, newrev, branch)