diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000000..1fc37ba8bc --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,36 @@ +name: Run pre-commit + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + pre-commit: + name: Run pre-commit hooks + runs-on: ubuntu-latest + steps: + - name: 'Checkout ${{ github.ref }} ( ${{ github.sha }} )' + uses: actions/checkout@v6 + with: + persist-credentials: false + - uses: actions/setup-python@v6 + with: + python-version: '3.13' + architecture: 'x64' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pre-commit + - name: set PY + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v5 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit + run: pre-commit run --color=always --all-files --show-diff-on-failure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..7cfbf9a5f4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: +- repo: meta + hooks: + - id: check-hooks-apply + name: check that hooks apply + description: check that all the hooks apply to the repository +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-ast + - id: check-case-conflict + - id: check-illegal-windows-names + - id: check-json + - id: check-merge-conflict + - id: check-yaml + - id: detect-private-key + # - id: end-of-file-fixer + # - id: fix-byte-order-marker + - id: forbid-submodules + - id: mixed-line-ending + - id: trailing-whitespace + files: \.(cgi|rdf|rb)$ diff --git a/www/members/nominate_board.cgi b/www/members/nominate_board.cgi index b748081dd0..18063dcb17 100755 --- a/www/members/nominate_board.cgi +++ b/www/members/nominate_board.cgi @@ -174,7 +174,7 @@ _html do _ %Q{ Use this form to nominate any Member for the ASF Board of Director election. It automatically adds a properly formatted nomination to the #{ASF::MemberFiles::NOMINATED_BOARD} file, - and will then + and will then } _strong "send an email to the #{MAILING_LIST} list" _ ' from you with the nomination, ' diff --git a/www/members/nominate_member.cgi b/www/members/nominate_member.cgi index 0ac3127967..fc210df278 100755 --- a/www/members/nominate_member.cgi +++ b/www/members/nominate_member.cgi @@ -156,12 +156,12 @@ _html do _ %Q{ Use this form to nominate any Committer the new ASF Membership election. It automatically adds a properly formatted nomination to the #{ASF::MemberFiles::NOMINATED_MEMBERS} file, - and will then + and will then } _strong "send an email to the #{MAILING_LIST} list" _ ' from you with the nomination, ' _a 'as is tradition.', href: 'https://lists.apache.org/list?members@apache.org:2023-2:%22MEMBER%20NOMINATION%22' - _p + _p _p do _ 'This form only supports adding new nominations of existing committers; ' _ 'there is now a form to ' diff --git a/www/members/update_board_nominations.cgi b/www/members/update_board_nominations.cgi index 5ff3bba026..e343ec488b 100755 --- a/www/members/update_board_nominations.cgi +++ b/www/members/update_board_nominations.cgi @@ -18,7 +18,7 @@ user = ASF::Auth.decode(env = {}) source = ASF::MeetingUtil.get_latest_svnpath(ASF::MemberFiles::NOMINATED_BOARD) def emit_form(url, revision, original, updated, diff, env) - + _whimsy_panel(url, style: 'panel-success') do _form.form_horizontal method: 'post' do _input type: 'hidden', name: 'original', value: original @@ -34,7 +34,7 @@ def emit_form(url, revision, original, updated, diff, env) field = 'difference' rows = nil rows = 1 + diff.split("\n").size if diff.size > 0 - _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, + _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, value: diff.size > 0 ? diff : '[No differences found]' ) end diff --git a/www/members/update_member_nominations.cgi b/www/members/update_member_nominations.cgi index 7b75cd1337..716d8262da 100755 --- a/www/members/update_member_nominations.cgi +++ b/www/members/update_member_nominations.cgi @@ -18,7 +18,7 @@ user = ASF::Auth.decode(env = {}) source = ASF::MeetingUtil.get_latest_svnpath(ASF::MemberFiles::NOMINATED_MEMBERS) def emit_form(url, revision, original, updated, diff, env) - + _whimsy_panel(url, style: 'panel-success') do _form.form_horizontal method: 'post' do _input type: 'hidden', name: 'original', value: original @@ -34,7 +34,7 @@ def emit_form(url, revision, original, updated, diff, env) field = 'difference' rows = nil rows = 1 + diff.split("\n").size if diff.size > 0 - _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, + _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, value: diff.size > 0 ? diff : '[No differences found]' ) end diff --git a/www/officers/update_affiliations.cgi b/www/officers/update_affiliations.cgi index 85aa769310..bbd5be8244 100755 --- a/www/officers/update_affiliations.cgi +++ b/www/officers/update_affiliations.cgi @@ -21,7 +21,7 @@ end source = File.join(ASF::SVN.svnurl!('officers'),'affiliations.txt') def emit_form(url, revision, original, updated, diff, env) - + _whimsy_panel(url, style: 'panel-success') do _form.form_horizontal method: 'post' do _input type: 'hidden', name: 'original', value: original @@ -37,7 +37,7 @@ def emit_form(url, revision, original, updated, diff, env) field = 'difference' rows = nil rows = 1 + diff.split("\n").size if diff.size > 0 - _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, + _whimsy_forms_input(label: 'Difference', name: field, id: field, rows: rows, readonly: true, value: diff.size > 0 ? diff : '[No differences found]' ) end diff --git a/www/roster/views/actions/memstat.json.rb b/www/roster/views/actions/memstat.json.rb index 76da5b000d..873b79043f 100644 --- a/www/roster/views/actions/memstat.json.rb +++ b/www/roster/views/actions/memstat.json.rb @@ -136,9 +136,9 @@ The membership withdrawal request that was registered for you has now been actioned. Your details have been removed from the membership roster. You have also been unsubscribed from members-only private email lists. - + Warm Regards, - + Secretary, Apache Software Foundation secretary@apache.org EOD @@ -161,9 +161,9 @@ body <<~EOD This acknowledges receipt of your request to rescind your membership withdrawal request. The request has been deleted, and your membership status will be unaffected. - + Warm Regards, - + Secretary, Apache Software Foundation secretary@apache.org EOD