fix: send GitHub webhook active flag as boolean (#25)

GitHub rejects webhook creation when gh api serializes active as a string. Use a typed field so gh sends a real boolean, and lock the gh/gosmee integration test harness to catch regressions.
This commit is contained in:
insleker 2026-04-08 23:57:30 +08:00
parent 4df29b1508
commit 5992ca1810
3 changed files with 20 additions and 2 deletions

View File

@ -158,7 +158,7 @@ class IssueTrackerClient {
_buildApiPath(repo, ['hooks']), _buildApiPath(repo, ['hooks']),
'-f', '-f',
'name=web', 'name=web',
'-f', '-F',
'active=true', 'active=true',
'-f', '-f',
'events[]=issues', 'events[]=issues',

View File

@ -145,7 +145,9 @@ projects:
final ghLogLines = await ghLog.readAsLines(); final ghLogLines = await ghLog.readAsLines();
expect( expect(
ghLogLines.any( ghLogLines.any(
(line) => line.contains('api -X POST repos/owner/sample/hooks'), (line) =>
line.contains('api -X POST repos/owner/sample/hooks') &&
line.contains('-F active=true'),
), ),
isTrue, isTrue,
); );

View File

@ -634,6 +634,22 @@ Future<void> writeGitHubGosmeeGhScript({
buffer buffer
..writeln('if [[ "\$1" == "api" && "\$4" == "repos/$repo/hooks" ]]; then') ..writeln('if [[ "\$1" == "api" && "\$4" == "repos/$repo/hooks" ]]; then')
..writeln(r''' active_flag=""''')
..writeln(r''' for ((i = 1; i <= $#; i += 1)); do''')
..writeln(r''' if [[ "${!i}" == "active=true" ]]; then''')
..writeln(r''' prev_index=$((i - 1))''')
..writeln(r''' active_flag="${!prev_index}"''')
..writeln(r''' break''')
..writeln(r''' fi''')
..writeln(r''' done''')
..writeln(
r''' if [[ "$active_flag" != "-F" && "$active_flag" != "--field" ]]; then''',
)
..writeln(
r''' echo "expected active=true to be sent with -F/--field, got: $*" >&2''',
)
..writeln(r''' exit 1''')
..writeln(r''' fi''')
..writeln(" cat <<'JSON'") ..writeln(" cat <<'JSON'")
..writeln(jsonEncode({'id': webhookId})) ..writeln(jsonEncode({'id': webhookId}))
..writeln('JSON') ..writeln('JSON')