forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Add upstream submodule path helpers, detection checks, and tests; update npm scripts #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jooh
merged 1 commit into
upstream_as_submodule
from
codex/implement-upstream-submodule-cutover-step
Apr 3, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const cp = require('child_process'); | ||
|
|
||
| const repositoryRoot = path.join(__dirname, '..'); | ||
| const upstreamRoot = path.join(repositoryRoot, 'upstream'); | ||
| const requiredUpstreamFiles = [ | ||
| 'package.json', | ||
| 'src/spec-node/devContainersSpecCLI.ts', | ||
| ]; | ||
|
|
||
| function fail(message) { | ||
| console.error(message); | ||
| console.error('Run: git submodule update --init --recursive'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| if (!fs.existsSync(upstreamRoot) || !fs.statSync(upstreamRoot).isDirectory()) { | ||
| fail('Missing upstream/ submodule directory.'); | ||
| } | ||
|
|
||
| for (const relativePath of requiredUpstreamFiles) { | ||
| const absolutePath = path.join(upstreamRoot, relativePath); | ||
| if (!fs.existsSync(absolutePath)) { | ||
| fail(`Missing upstream submodule asset: upstream/${relativePath}`); | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| const status = cp.execFileSync('git', ['submodule', 'status', '--', 'upstream'], { | ||
| cwd: repositoryRoot, | ||
| encoding: 'utf8', | ||
| stdio: ['ignore', 'pipe', 'pipe'], | ||
| }).trim(); | ||
| if (!status) { | ||
| fail('Unable to determine upstream submodule status.'); | ||
| } | ||
| if (status.startsWith('-')) { | ||
| fail('upstream submodule is not initialized.'); | ||
| } | ||
| } catch (error) { | ||
| fail(`Unable to resolve upstream submodule status: ${error instanceof Error ? error.message : 'unknown error'}`); | ||
| } | ||
|
|
||
| console.log('Upstream submodule check passed.'); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import path from 'path'; | ||
|
|
||
| export const DEFAULT_UPSTREAM_SUBMODULE_ROOT = 'upstream'; | ||
|
|
||
| export function buildUpstreamPath(...segments: string[]) { | ||
| return path.posix.join(DEFAULT_UPSTREAM_SUBMODULE_ROOT, ...segments); | ||
| } | ||
|
|
||
| export const UPSTREAM_CONTAINER_FEATURES_TEST_GLOB = buildUpstreamPath('src', 'test', 'container-features', '*.test.ts'); | ||
| export const UPSTREAM_CONTAINER_FEATURES_CLI_TEST_PATH = buildUpstreamPath('src', 'test', 'container-features', 'featuresCLICommands.test.ts'); | ||
| export const UPSTREAM_CONTAINER_TEMPLATES_TEST_GLOB = buildUpstreamPath('src', 'test', 'container-templates', '*.test.ts'); | ||
| export const UPSTREAM_TEST_TSCONFIG_PATH = buildUpstreamPath('src', 'test', 'tsconfig.json'); |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { expect } from 'chai'; | ||
|
|
||
| import { | ||
| DEFAULT_UPSTREAM_SUBMODULE_ROOT, | ||
| UPSTREAM_CONTAINER_FEATURES_CLI_TEST_PATH, | ||
| UPSTREAM_CONTAINER_FEATURES_TEST_GLOB, | ||
| UPSTREAM_CONTAINER_TEMPLATES_TEST_GLOB, | ||
| UPSTREAM_TEST_TSCONFIG_PATH, | ||
| buildUpstreamPath, | ||
| } from '../spec-node/migration/upstreamPaths'; | ||
|
|
||
| describe('upstream path helpers', () => { | ||
| it('builds upstream paths from canonical submodule root', () => { | ||
| expect(buildUpstreamPath('src', 'test', 'tsconfig.json')).to.equal('upstream/src/test/tsconfig.json'); | ||
| expect(DEFAULT_UPSTREAM_SUBMODULE_ROOT).to.equal('upstream'); | ||
| }); | ||
|
|
||
| it('exposes shared npm script path constants for upstream test suites', () => { | ||
| expect(UPSTREAM_TEST_TSCONFIG_PATH).to.equal('upstream/src/test/tsconfig.json'); | ||
| expect(UPSTREAM_CONTAINER_FEATURES_TEST_GLOB).to.equal('upstream/src/test/container-features/*.test.ts'); | ||
| expect(UPSTREAM_CONTAINER_FEATURES_CLI_TEST_PATH).to.equal('upstream/src/test/container-features/featuresCLICommands.test.ts'); | ||
| expect(UPSTREAM_CONTAINER_TEMPLATES_TEST_GLOB).to.equal('upstream/src/test/container-templates/*.test.ts'); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new path-candidate regex does not include
*/**, so common script arguments likesrc/test/**/*.test.tsare truncated tosrc/testbefore validation. In practice this can hide real root-level upstream references: ifsrc/testexists locally (as it does here),includeExistingLocalPathssuppresses the match and the scanner reports no issue even though the original command still points at a non-upstream/path. This weakens the migration/readiness check for mocha-style globbed test commands.Useful? React with 👍 / 👎.