8000 Merge pull request #1 from sunaoka/feature/generator · sunaoka/php-postgresql-errors@9ccc3a8 · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9ccc3a8

Browse files
authored
Merge pull request #1 from sunaoka/feature/generator
Added comment generation.
2 parents eea5240 + 571d75d commit 9ccc3a8

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

.github/workflows/generate.yaml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: generate
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
run:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.0'
17+
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Generate
22+
run: make
23+
24+
- name: Count changes
25+
id: changes
26+
run: |
27+
git add -N .
28+
echo "::set-output name=count::$(git diff --name-only | wc -l)"
29+
30+
- name: Create Pull Request
31+
uses: peter-evans/create-pull-request@v3
32+
with:
33+
commit-message: Update Error Code
34+
delete-branch: true
35+
title: Update Error Code
36+
body: |
37+
Error codes have been updated.
38+
39+
- https://github.com/postgres/postgres/blob/master/src/backend/utils/errcodes.txt
40+
if: ${{ steps.changes.outputs.count > 0 }}

tools/generator.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
$const = array();
55

66
while ($row = fgets(STDIN)) {
7-
if (preg_match('/^([0-9A-Z]{5}) +[SWE] +[^ ]+? +([a-z_]+)$/', $row, $matches)) {
7+
if (preg_match('/^Section: (Class .*)$/', $row, $matches)) {
8+
$const[] = '';
9+
$const[] = " // {$matches[1]}";
10+
} elseif (preg_match('/^([0-9A-Z]{5}) +[SWE] +[^ ]+? +([a-z_]+)$/', $row, $matches)) {
811
$key = strtoupper($matches[2]);
912
if (isset($codes[$key])) {
1013
$key .= '_EXCEPTION';
@@ -14,7 +17,7 @@
1417
}
1518
}
1619

17-
$const = implode(PHP_EOL, $const);
20+
$const = trim(implode(PHP_EOL, $const), PHP_EOL);
1821

1922
echo <<<EOD
2023
<?php

0 commit comments

Comments
 (0)
0