Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test-remote-vs-local-generation-parity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ on:
branches:
- main

# Cancel previous workflows when another is triggered
# Let the current run finish, but cancel any queued (pending) runs in favor of the newest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: false

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/cli/versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
- version: 3.77.1
changelogEntry:
- summary: |
Scope PR update feature for self-hosted GitHub generation to the current generator by
including the generator name in the branch prefix (e.g. fern-bot/fernapi-fern-typescript-sdk/).
This prevents concurrent generators targeting the same repository from racing on the same PR.
type: fix
createdAt: "2026-02-13"
irVersion: 65

- version: 3.77.0
changelogEntry:
- summary: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ export async function runLocalGenerationForWorkspace({
interactiveTaskContext,
selfhostedGithubConfig,
absolutePathToLocalOutput,
autoVersioningCommitMessage
autoVersioningCommitMessage,
generatorInvocation.name
);
}
});
Expand Down Expand Up @@ -361,7 +362,8 @@ async function findExistingUpdatablePR(
owner: string,
repo: string,
baseBranch: string,
context: TaskContext
context: TaskContext,
branchPrefix: string
): Promise<ExistingPullRequest | undefined> {
try {
const { data: pulls } = await octokit.pulls.list({
Expand All @@ -381,8 +383,10 @@ async function findExistingUpdatablePR(
continue;
}

if (!pr.head.ref.startsWith("fern-bot/")) {
context.logger.debug(`PR #${pr.number} skipped: branch ${pr.head.ref} does not start with fern-bot/`);
if (!pr.head.ref.startsWith(branchPrefix)) {
context.logger.debug(
`PR #${pr.number} skipped: branch ${pr.head.ref} does not start with ${branchPrefix}`
);
continue;
}

Expand Down Expand Up @@ -453,18 +457,25 @@ async function checkPRHasOnlyGenerationCommits(
}
}

function sanitizeGeneratorNameForBranch(generatorName: string): string {
return generatorName.replace(/\//g, "-");
}

async function postProcessGithubSelfHosted(
context: TaskContext,
selfhostedGithubConfig: SelhostedGithubConfig,
absolutePathToLocalOutput: AbsoluteFilePath,
commitMessage?: string
commitMessage?: string,
generatorName?: string
): Promise<void> {
try {
context.logger.debug("Starting GitHub self-hosted flow in directory: " + absolutePathToLocalOutput);
const repository = ClonedRepository.createAtPath(absolutePathToLocalOutput);
const now = new Date();
const formattedDate = now.toISOString().replace("T", "_").replace(/:/g, "-").replace("Z", "").replace(".", "_");
const newPrBranch = `fern-bot/${formattedDate}`;
const sanitizedName = generatorName != null ? sanitizeGeneratorNameForBranch(generatorName) : undefined;
const branchPrefix = sanitizedName != null ? `fern-bot/${sanitizedName}/` : "fern-bot/";
const newPrBranch = `${branchPrefix}${formattedDate}`;
// Ensure git commits are attributed to a bot user so pushes/PRs have a consistent author.
try {
// Use repository helper to set git user/email if available
Expand All @@ -487,7 +498,14 @@ async function postProcessGithubSelfHosted(
const parsedRepo = parseRepository(selfhostedGithubConfig.uri);
const { owner, repo } = parsedRepo;

const existingPR = await findExistingUpdatablePR(octokit, owner, repo, baseBranch, context);
const existingPR = await findExistingUpdatablePR(
octokit,
owner,
repo,
baseBranch,
context,
branchPrefix
);

let prBranch: string;
let isUpdatingExistingPR = false;
Expand Down
Loading