Repository navigation
feat(work-items): add get-field-options tracker verb for size field values #9111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kyle-sexton
merged 5 commits into
main
from
work-resolve-issue/issue-8324-39811783375-1
Oct 23, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
34c3cef
Resolve issue #8324
melodic-automation-lanes[bot] 3a1900e
Resolve issue #8324
melodic-automation-lanes[bot] 3e13727
Merge branch 'main' into work-resolve-issue/issue-8324-39811783375-1
kyle-sexton b457958
Merge branch 'main' into work-resolve-issue/issue-8324-39811783375-1
kyle-sexton 76e2cba
fix(work-items): declare get-field-options in generator fixture and m…
kyle-sexton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
.changes/work-items/feat-8324-get-field-options-3a9d4c71.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| bump: minor | ||
| --- | ||
|
|
||
| ### Added | ||
|
|
||
| - The tracker seam's `get-field-options --field <name-or-id> [--repo <owner>/<repo>]` verb reads | ||
| the options of one single-select issue field, so a caller such as planning's Work size can use a | ||
| tracker's own size values. The GitHub adapter implements it from the organization issue-field | ||
| listing `set-fields` validates against; a field the organization lacks prints an empty | ||
| `options` list and exits 0, and an adapter that declares no `get-field-options` key exits 6 | ||
| (unsupported). The other bundled adapters' manifests, the adapter generator's verb list and the | ||
| adapter-spec reference now declare the verb too (`false` outside GitHub). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
plugins/work-items/tools/work-item-tracker/adapters/github/get-field-options.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env bash | ||
| # get-field-options --field <name-or-id> [--repo <owner>/<repo>] — CONTRACT.md "Verbs (core public | ||
| # surface)". Read-only. Lists the options of one single-select organization issue field, from the | ||
| # same listing set-fields validates against (GET orgs/{org}/issue-fields). The field is matched by | ||
| # its exact name or its numeric id. A field the organization does not have, or one with no options, | ||
| # yields an empty list and exit 0, so a caller falls back to its own defaults. | ||
| set -uo pipefail | ||
| # shellcheck source=common.sh | ||
| source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common.sh" | ||
|
|
||
| usage="usage: get-field-options --field <name-or-id> [--repo <owner>/<repo>]" | ||
| wit_help_if_requested "$usage" "$@" | ||
|
|
||
| field="" repo_override="" | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --field) | ||
| [[ $# -ge 2 && -n "$2" && -z "$field" ]] || wit_usage_error "--field needs one non-empty value" | ||
| field="$2" | ||
| shift 2 | ||
| ;; | ||
| --repo) | ||
| [[ $# -ge 2 && -n "$2" ]] || wit_usage_error "--repo needs a value" | ||
| repo_override="$2" | ||
| shift 2 | ||
| ;; | ||
| *) wit_usage_error "unknown argument: $1" ;; | ||
| esac | ||
| done | ||
| [[ -n "$field" ]] || wit_usage_error "$usage" | ||
| [[ -z "$repo_override" || "$repo_override" =~ ^[^/]+/[^/]+$ ]] || | ||
| wit_usage_error "--repo must be <owner>/<repo> (got: $repo_override)" | ||
|
|
||
| # $() swallows wit_run_gh's exit-on-error; propagate its code (see create-item.sh). | ||
| target_repo="$(wit_resolve_repo "$repo_override")" || exit "$?" | ||
| owner="${target_repo%%/*}" | ||
|
|
||
| wit_run_gh read api -H "X-GitHub-Api-Version: 2026-03-10" "orgs/$owner/issue-fields" | ||
| options="$(jq -c --arg f "$field" '[.[] | select((.id | tostring) == $f or .name == $f) | ||
| | .options // [] | .[] | {id, name}]' <<<"$WIT_GH_OUT")" || { | ||
| echo "get-field-options: org issue-field listing for $owner is not JSON" >&2 | ||
| exit "$EX_INTERNAL" | ||
| } | ||
|
|
||
| jq -nc --arg sv "$WIT_SCHEMA_VERSION" --arg field "$field" --argjson options "$options" \ | ||
| '{schema_version: $sv, field: $field, options: $options}' |
76 changes: 76 additions & 0 deletions
76
plugins/work-items/tools/work-item-tracker/adapters/github/get-field-options.test.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| #!/usr/bin/env bash | ||
| # shellcheck disable=SC2154 # FAILED/CASE_NUM initialized by the sourced helper | ||
| # Offline: get-field-options against a gh stub. The org field listing is the trimmed recording | ||
| # set-fields.test.sh uses (GET orgs/melodic-software/issue-fields, 2026-10-18). | ||
| set -uo pipefail | ||
| unset GIT_DIR GIT_WORK_TREE GIT_CONFIG | ||
|
|
||
| TMP_ROOT="$(mktemp -d)" | ||
| trap 'rm -rf "$TMP_ROOT"' EXIT | ||
| S="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/get-field-options.sh" | ||
| source "$(dirname "$S")/../../lib/verb-test-helpers.sh" | ||
|
|
||
| assert_help "$S" | ||
| assert_usage_error "$S" # no --field | ||
| assert_usage_error "$S" --field # no value | ||
| assert_usage_error "$S" --field Size --field Complexity # one field only | ||
| assert_usage_error "$S" --field Size --repo notarepo # malformed --repo | ||
| assert_usage_error "$S" --field Size --bogus | ||
|
|
||
| command -v jq >/dev/null 2>&1 || skip_suite "jq not on PATH" | ||
|
|
||
| STUB="$TMP_ROOT/bin" | ||
| LOG="$TMP_ROOT/gh.log" | ||
| mkdir -p "$STUB" | ||
| cat >"$STUB/gh" <<'EOF' | ||
| #!/usr/bin/env bash | ||
| printf '%s\n' "$*" >>"$GH_STUB_LOG" | ||
| for a in "$@"; do | ||
| case "$a" in | ||
| orgs/*/issue-fields) | ||
| [[ -z "${GH_STUB_ERR:-}" ]] || { printf '%s\n' "$GH_STUB_ERR" >&2; exit 1; } | ||
| cat <<'JSON' | ||
| [{"data_type":"single_select","id":15462270,"name":"Size","options":[{"id":27053566,"name":"Large"},{"id":27053567,"name":"Medium"},{"id":27053568,"name":"Small"}]}, | ||
| {"data_type":"single_select","id":48625720,"name":"Complexity","options":[{"id":85127653,"name":"High"},{"id":85127651,"name":"Low"}]}, | ||
| {"data_type":"date","id":7,"name":"Target date","options":null}] | ||
| JSON | ||
| exit 0 | ||
| ;; | ||
| esac | ||
| done | ||
| printf 'gh-stub: unhandled %s\n' "$*" >&2 | ||
| exit 90 | ||
| EOF | ||
| chmod +x "$STUB/gh" | ||
|
|
||
| run() { | ||
| : >"$LOG" | ||
| OUT="$(PATH="$STUB:$PATH" GH_STUB_LOG="$LOG" bash "$S" "$@" 2>"$TMP_ROOT/err")" | ||
| RC=$? | ||
| ERR="$(<"$TMP_ROOT/err")" | ||
| } | ||
|
|
||
| run --field Size --repo o/r | ||
| assert_eq "named field → exit 0" "0" "$RC" | ||
| assert_eq "lists the field's options" '[{"id":27053566,"name":"Large"},{"id":27053567,"name":"Medium"},{"id":27053568,"name":"Small"}]' \ | ||
| "$(jq -c '.options' <<<"$OUT")" | ||
| assert_eq "output echoes the requested field" "Size" "$(jq -r '.field' <<<"$OUT")" | ||
| assert_contains "reads the repo owner's org" "$(head -n 1 "$LOG")" "orgs/o/issue-fields" | ||
|
|
||
| run --field 48625720 --repo o/r | ||
| assert_eq "field by numeric id → exit 0" "0" "$RC" | ||
| assert_eq "field by id lists its options" '["High","Low"]' "$(jq -c '[.options[].name]' <<<"$OUT")" | ||
|
|
||
| run --field Missing --repo o/r | ||
| assert_eq "absent field → exit 0" "0" "$RC" | ||
| assert_eq "absent field → empty list" "[]" "$(jq -c '.options' <<<"$OUT")" | ||
|
|
||
| run --field "Target date" --repo o/r | ||
| assert_eq "field with no options → exit 0" "0" "$RC" | ||
| assert_eq "field with no options → empty list" "[]" "$(jq -c '.options' <<<"$OUT")" | ||
|
|
||
| GH_STUB_ERR="HTTP 403: Forbidden" run --field Size --repo o/r | ||
| assert_eq "failed listing → mapped auth exit" "4" "$RC" | ||
| assert_contains "failed listing → gh error reaches stderr" "$ERR" "HTTP 403" | ||
|
|
||
| [[ $FAILED -eq 0 ]] || exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.