Skip to content

Add --project flag to chunk task config for large CircleCI accounts - #428

Open
hidetaka-cci wants to merge 1 commit into
CircleCI-Public:mainfrom
hidetaka-cci:fix/task-config-project-flag
Open

Add --project flag to chunk task config for large CircleCI accounts#428
hidetaka-cci wants to merge 1 commit into
CircleCI-Public:mainfrom
hidetaka-cci:fix/task-config-project-flag

Conversation

@hidetaka-cci

Copy link
Copy Markdown
Contributor
  • Add --project <slug> to chunk task config so users can skip the followed-projects picker when they already know the project slug (e.g. gh/CircleCI-Public/chunk-cli).
  • When --project is set, skip ListFollowedProjects and ListCollaborations, and resolve org/project IDs via GetProjectBySlug.
  • Fix GetProjectBySlug org ID parsing: the v2 API returns organization_id, not org_id. This was a latent bug surfaced while testing the new flag against the live API.
  • Add a regression test with a live API-shaped JSON fixture so the organization_id field is not dropped on decode.

Closes #427

Motivation

chunk task config lists every followed project in a single TTY picker with no search or filter. On an account with 438 followed projects, scrolling to the target repo is impractical. Users who already know the project slug — typically from the repo they are standing in — should be able to pass it directly.

Definition ID discovery is out of scope for this PR. The wizard still prompts for definition UUID and other fields interactively.

Usage

chunk task config --project gh/CircleCI-Public/chunk-cli

Only the project-selection step is skipped. The wizard continues with definition name, definition UUID, default branch, and optional environment ID.

Changes

Area Change
internal/cmd/task.go --project flag; skip project/collab fetch when set
internal/task/collect.go CollectOptions.ProjectSlug; resolveProjectFromSlug
internal/circleci/projects.go Fix organization_id JSON tag on ProjectDetail
internal/circleci/circleci_test.go Regression test with live API JSON fixture
internal/testing/fakes/circleci.go Fake GET /api/v2/project/:slug endpoint for tests
docs/CLI.md Document --project flag

Bug fix note

While verifying --project against the live API, GetProjectBySlug returned an empty org ID. The API response uses organization_id, but ProjectDetail was tagged as org_id. This likely affected the interactive list-selection path as well, not only --project. The fix and regression test are included in this PR.

Commits

  1. Add --project flag to task config for large CircleCI accounts.
  2. Add regression test for GetProjectBySlug organization_id parsing.

Test plan

  • go test -race ./internal/task/ ./internal/circleci/ ./internal/cmd/
  • TestGetProjectBySlug_decodesOrganizationIDFromAPIResponse — raw JSON fixture matches live API shape; fails if org_id tag is used instead of organization_id
  • Sidecar: sync + remote tests for changed packages
  • Manual: ./dist/chunk task config --project gh/CircleCI-Public/chunk-cli skips project list and proceeds to definition prompts
  • Live API: GetProjectBySlug returns org ID after organization_id fix

Skip fetching and scrolling through followed projects when the slug is
already known, and fix GetProjectBySlug org ID parsing for organization_id.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chunk task config project picker does not scale for large CircleCI accounts

1 participant