diff --git a/CHANGELOG.md b/CHANGELOG.md index bcc8ec7e4..498fa9b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed Ask GitHub landing page chat box placement to be centered on the page instead of at the bottom. [#1046](https://github.com/sourcebot-dev/sourcebot/pull/1046) +- Fixed issue where local git connections (`file://`) would fail when matching a file instead of a directory. [#1049](https://github.com/sourcebot-dev/sourcebot/pull/1049) ## [4.16.2] - 2026-03-25 diff --git a/packages/backend/src/repoCompileUtils.ts b/packages/backend/src/repoCompileUtils.ts index 9307e9b29..eecb9fb27 100644 --- a/packages/backend/src/repoCompileUtils.ts +++ b/packages/backend/src/repoCompileUtils.ts @@ -14,6 +14,7 @@ import { createLogger } from '@sourcebot/shared'; import { BitbucketConnectionConfig, GerritConnectionConfig, GiteaConnectionConfig, GitlabConnectionConfig, GenericGitHostConnectionConfig, AzureDevOpsConnectionConfig } from '@sourcebot/schemas/v3/connection.type'; import { ProjectVisibility } from "azure-devops-node-api/interfaces/CoreInterfaces.js"; import path from 'path'; +import fs from 'fs/promises'; import { glob } from 'glob'; import { getLocalDefaultBranch, getOriginUrl, isPathAValidGitRepoRoot, isUrlAValidGitRepo } from './git.js'; import assert from 'assert'; @@ -611,6 +612,14 @@ export const compileGenericGitHostConfig_file = async ( logger.info(`Found ${repoPaths.length} path(s) matching pattern '${configUrl.pathname}'`); await Promise.all(repoPaths.map((repoPath) => gitOperationLimit(async () => { + const stat = await fs.stat(repoPath).catch(() => null); + if (!stat || !stat.isDirectory()) { + const warning = `Skipping ${repoPath} - path is not a directory.`; + logger.warn(warning); + warnings.push(warning); + return; + } + const isGitRepo = await isPathAValidGitRepoRoot({ path: repoPath, });