Skip to content

feat(cli): detect Postman deploy source from git commit message#14768

Open
matlegault wants to merge 6 commits intomainfrom
devin/1775682123-postman-source-tracking
Open

feat(cli): detect Postman deploy source from git commit message#14768
matlegault wants to merge 6 commits intomainfrom
devin/1775682123-postman-source-tracking

Conversation

@matlegault
Copy link
Copy Markdown
Contributor

@matlegault matlegault commented Apr 8, 2026

Description

Refs fern-api/fern-platform#9560 (companion PR)

Adds support for detecting when a docs deployment was triggered by a Postman collection update, by inspecting the git commit message for a [source:postman] marker. When found, the CLI includes deploySource: "postman" in the X-CI-Source JSON header sent to FDR during docs publishing, so the dashboard can show a Postman indicator in the deployment activity log.

This approach detects the source directly from the commit message rather than requiring a custom workflow step to set an env var — meaning it works for all existing Postman-integrated repos on day one without any workflow template changes.

Changes Made

  • Added deploySource?: string field to the CISource interface (in all three locations where it's defined)
  • Added detectDeploySource() helper that runs git log -1 --format=%s and checks for [source:postman] in the commit subject
  • detectCISource() now calls detectDeploySource() only after a CI environment is confirmed — the git exec is never spawned on local dev machines
  • Refactored detectCISource() from separate if blocks with early returns to an if/else if chain that builds a source object, then conditionally enriches it with deploySource
  • The git call is wrapped in try/catch with a 5s timeout and stdio: "pipe" to prevent stderr from leaking to the user's terminal when git is unavailable
  • Errors are logged at console.debug level for diagnosability
  • Added versions.yml entry for v4.67.0 (minor bump for feat)

Testing

  • Unit tests added/updated
  • Lint passes (pnpm run check)
  • Biome passes (pnpm check:biome)
  • Manual testing completed

Reviewer Checklist

  • Synchronous shell exec: detectDeploySource() uses execSync which blocks the event loop. The 5s timeout bounds the worst case, and this only runs once per CLI invocation and only when already inside a recognized CI environment. Worth confirming this is acceptable.
  • Commit message detection scope: git log -1 --format=%s reads the HEAD commit subject. For merge commits or squash merges, verify the [source:postman] marker propagates to the final commit subject (the fern-platform companion PR controls the commit message format).
  • Three CISource interfaces: The field was added to all three duplicate definitions (environment.ts, publishDocs.ts, runRemoteGenerationForDocsWorkspace.ts). The duplication is pre-existing.
  • No unit tests: detectDeploySource() shells out to git so it's not easily unit-testable without mocking execSync. The function is small and defensive (try/catch + timeout). Consider whether integration coverage is sufficient.
  • Backward-compatible: The field is optional and only included when the marker is detected, so existing deployments are unaffected.
  • FDR compatibility: deploySource is a new non-URL string field in the X-CI-Source JSON. FDR's sanitizeCiSource only strips URL fields (runUrl), so this passes through untouched. No FDR changes needed.

Updates since last revision

  • Deferred detectDeploySource(): Moved the execSync git call so it only runs after a CI environment (GitHub/GitLab/Bitbucket) has been confirmed. Previously it ran unconditionally at the top of detectCISource(), which could block local dev machines for up to 5s with no benefit.
  • Refactored control flow: Changed detectCISource() from separate if blocks with early returns to if/else if chain, building a source variable that gets enriched with deploySource before returning.
  • Version bumped to 4.67.0: Main branch added its own 4.66.0 entry, so our entry is now 4.67.0.

Link to Devin session: https://app.devin.ai/sessions/9b2a038d4ebb47039520482f78e4a254
Requested by: @matlegault


Open with Devin

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775682123-postman-source-tracking branch from 6c60ed6 to 1e0b7dd Compare April 8, 2026 21:30
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration bot changed the title feat: read FERN_DEPLOY_SOURCE env var and include in X-CI-Source header feat(cli): read FERN_DEPLOY_SOURCE env var and include in X-CI-Source header Apr 8, 2026
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775682123-postman-source-tracking branch 4 times, most recently from 030b37b to 4ac2818 Compare April 9, 2026 17:28
@devin-ai-integration devin-ai-integration bot changed the title feat(cli): read FERN_DEPLOY_SOURCE env var and include in X-CI-Source header feat(cli): detect Postman deploy source from git commit message Apr 9, 2026
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775682123-postman-source-tracking branch 3 times, most recently from 23e81c6 to f40db0a Compare April 10, 2026 14:01
devin-ai-integration[bot]

This comment was marked as resolved.

publishing. This allows Postman-triggered deployments to be identified
in the dashboard activity log without requiring workflow template changes.
type: feat
createdAt: "2026-04-08"
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.

The createdAt date for version 4.66.0 is "2026-04-08", which is earlier than the createdAt date of the older version 4.65.3 ("2026-04-10"). This creates a chronological inconsistency where a newer version has an earlier creation date than an older version.

If the versioning system or changelog relies on chronological ordering, this could cause issues with:

  • Version sorting/ordering
  • Changelog generation
  • Release timelines

Fix: Update the createdAt date to match or be later than the current date:

createdAt: "2026-04-10"
Suggested change
createdAt: "2026-04-08"
createdAt: "2026-04-10"

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration bot and others added 5 commits April 10, 2026 16:10
Co-Authored-By: mathieu <mathieu@buildwithfern.com>
… var

Read the git commit subject via 'git log -1 --format=%s' and check for
the [source:postman] marker. This removes the dependency on the
FERN_DEPLOY_SOURCE env var and works for all repos immediately without
requiring a workflow template update.

Co-Authored-By: mathieu <mathieu@buildwithfern.com>
Co-Authored-By: mathieu <mathieu@buildwithfern.com>
Co-Authored-By: mathieu <mathieu@buildwithfern.com>
Co-Authored-By: mathieu <mathieu@buildwithfern.com>
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1775682123-postman-source-tracking branch from a3663f7 to 3bd3e59 Compare April 10, 2026 16:11
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

Comment thread packages/cli/cli/src/utils/environment.ts Outdated
Co-Authored-By: mathieu <mathieu@buildwithfern.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant