Add --project flag to chunk task config for large CircleCI accounts - #428
Open
hidetaka-cci wants to merge 1 commit into
Open
Add --project flag to chunk task config for large CircleCI accounts#428hidetaka-cci wants to merge 1 commit into
--project flag to chunk task config for large CircleCI accounts#428hidetaka-cci wants to merge 1 commit into
Conversation
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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
--project <slug>tochunk task configso users can skip the followed-projects picker when they already know the project slug (e.g.gh/CircleCI-Public/chunk-cli).--projectis set, skipListFollowedProjectsandListCollaborations, and resolve org/project IDs viaGetProjectBySlug.GetProjectBySlugorg ID parsing: the v2 API returnsorganization_id, notorg_id. This was a latent bug surfaced while testing the new flag against the live API.organization_idfield is not dropped on decode.Closes #427
Motivation
chunk task configlists 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
Only the project-selection step is skipped. The wizard continues with definition name, definition UUID, default branch, and optional environment ID.
Changes
internal/cmd/task.go--projectflag; skip project/collab fetch when setinternal/task/collect.goCollectOptions.ProjectSlug;resolveProjectFromSluginternal/circleci/projects.goorganization_idJSON tag onProjectDetailinternal/circleci/circleci_test.gointernal/testing/fakes/circleci.goGET /api/v2/project/:slugendpoint for testsdocs/CLI.md--projectflagBug fix note
While verifying
--projectagainst the live API,GetProjectBySlugreturned an empty org ID. The API response usesorganization_id, butProjectDetailwas tagged asorg_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
--projectflag to task config for large CircleCI accounts.GetProjectBySlugorganization_idparsing.Test plan
go test -race ./internal/task/ ./internal/circleci/ ./internal/cmd/TestGetProjectBySlug_decodesOrganizationIDFromAPIResponse— raw JSON fixture matches live API shape; fails iforg_idtag is used instead oforganization_id./dist/chunk task config --project gh/CircleCI-Public/chunk-cliskips project list and proceeds to definition promptsGetProjectBySlugreturns org ID afterorganization_idfix