Skip to content

feat: infer --pipeline from heroku.remote git config in CI commands (W-23597910, #1318) - #3845

Open
heroku-johnny wants to merge 3 commits into
mainfrom
W-23597910
Open

feat: infer --pipeline from heroku.remote git config in CI commands (W-23597910, #1318)#3845
heroku-johnny wants to merge 3 commits into
mainfrom
W-23597910

Conversation

@heroku-johnny

Copy link
Copy Markdown
Contributor

Summary

  • Wires --remote flag and heroku.remote git config into getPipeline() in src/lib/ci/pipelines.ts, so CI commands (ci:run, ci:rerun, ci:debug, ci:info, ci:last, ci:open, ci:config, etc.) can resolve their pipeline the same way heroku run and other app-flag commands already do
  • Adds a protected resolveAppFromRemote() helper on PipelineService that calls configRemote() / getGitRemotes() from @heroku-cli/command, keeping the git resolution logic injectable and testable via subclassing
  • Updates getPipeline's flag type signature to include remote?: null | string

What changed

src/lib/ci/pipelines.ts:

  • Import configRemote and getGitRemotes from @heroku-cli/command
  • Before erroring on missing --pipeline/--app, try to resolve an app from flags.remote or the heroku.remote git config value; if a matching Heroku git remote is found, use that app to look up the pipeline coupling as usual

test/unit/lib/ci/pipelines.unit.test.ts:

  • Add three new test cases under a remote inference block that cover: resolution via --remote, resolution via git config, and the fall-through error when no remote resolves an app

Why

Fixes GUS W-23597910 / GitHub #1318. Users who set heroku.remote in their git config (or pass --remote) expect CI commands to pick up the pipeline automatically, consistent with all other Heroku CLI commands that accept --remote.

Test plan

  • test/unit/lib/ci/pipelines.unit.test.ts — 5 tests pass (3 new + 2 existing)
  • test/unit/commands/ci/run.unit.test.ts — 3 tests pass
  • test/unit/commands/ci/rerun.unit.test.ts — 3 tests pass
  • npm run build — TypeScript compiles cleanly
  • npx eslint src/lib/ci/pipelines.ts test/unit/lib/ci/pipelines.unit.test.ts — 0 errors, 2 pre-existing any warnings

🤖 Generated with Claude Code

…W-23597910, #1318)

When neither --pipeline nor --app is provided, CI commands now resolve the
target app from the --remote flag or heroku.remote git config, matching the
behavior of heroku run and other app-flag commands.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dev Tools Standards Review Results (machine-generated)

🟡 2 advisory.

Comment thread src/lib/ci/pipelines.ts
if ((!flags.pipeline) && (!flags.app)) {
// Resolve app from --remote flag or heroku.remote git config when --pipeline and --app are absent
let resolvedApp = flags.app
if (!flags.pipeline && !resolvedApp) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge-duplicate-conditionals (Code style · minor · 50% confidence): It looks like we're checking the same predicate !flags.pipeline && !resolvedApp in two consecutive if blocks — one to resolve the app from the remote, the next to emit the required-flag error. Should we merge them into a single block that owns the condition (attempt resolution, then error if it's still unresolved) so the predicate only lives in one place?

import {APIClient} from '@heroku-cli/command'
import {expect} from 'chai'
import nock from 'nock'
import {createSandbox} from 'sinon'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete-unused-code (Code style · minor · 85% confidence): It looks like the sinon sandbox (createSandbox import, the sandbox variable, and its beforeEach/afterEach) is set up but never used — all three tests inject behavior by subclassing PipelineService and overriding resolveAppFromRemote. Should we delete the sandbox scaffolding, or wire the tests to stub through it instead?

@michaelmalave michaelmalave left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some non-blocking comments - code functionality tested and confirmed. Nice!

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.

2 participants