-
Notifications
You must be signed in to change notification settings - Fork 447
Proj/git semantics #327
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
Proj/git semantics #327
Changes from all commits
2746238
e37aac6
99f44d8
184fc6f
1136707
5a0077d
d1c3583
efb6cb5
620c89b
b33226d
c6c5e9b
0d1fbf0
a685b70
4a9bc00
e3add8d
efb6396
ddb1f22
69f8465
8b87577
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,11 +12,16 @@ export default class VcCommit extends Command { | |||||
| description: 'Commit message', | ||||||
| }), | ||||||
| } | ||||||
| public static strict = false | ||||||
|
|
||||||
| public async run(): Promise<void> { | ||||||
| const {flags} = await this.parse(VcCommit) | ||||||
| const {argv, flags} = await this.parse(VcCommit) | ||||||
|
|
||||||
| const {message} = flags | ||||||
| // Support unquoted multi-word messages: brv vc commit -m hello world | ||||||
| const extra = (argv as string[]).join(' ') | ||||||
| const message = flags.message | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (standards):
Suggested change
|
||||||
| ? (extra ? `${flags.message} ${extra}` : flags.message) | ||||||
| : (extra || undefined) | ||||||
| if (!message) { | ||||||
| this.error('Usage: brv vc commit -m "<message>"') | ||||||
| } | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import {Command} from '@oclif/core' | ||
|
|
||
| export default class Vc extends Command { | ||
| public static description = 'Version control commands for the context tree' | ||
| public static examples = ['<%= config.bin %> <%= command.id %> --help'] | ||
|
|
||
| public async run(): Promise<void> { | ||
| await this.config.runCommand('help', ['vc']) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,50 +1,15 @@ | ||||||
| /** | ||||||
| * Build the CoGit Git remote URL for a given team and space. | ||||||
| * Format: {gitApiBaseUrl}/git/{teamId}/{spaceId}.git | ||||||
| * Format: {baseUrl}/{teamName}/{spaceName}.git | ||||||
| */ | ||||||
| export function buildCogitRemoteUrl(baseUrl: string, teamId: string, spaceId: string): string { | ||||||
| export function buildCogitRemoteUrl(baseUrl: string, teamName: string, spaceName: string): string { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (docs): JSDoc says
Suggested change
|
||||||
| const base = baseUrl.replace(/\/$/, '') | ||||||
| return `${base}/git/${teamId}/${spaceId}.git` | ||||||
| return `${base}/${teamName}/${spaceName}.git` | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Remove credentials from a URL, returning only the host + path. | ||||||
| */ | ||||||
| export function stripCredentialsFromUrl(url: string): string { | ||||||
| try { | ||||||
| const parsed = new URL(url) | ||||||
| parsed.username = '' | ||||||
| parsed.password = '' | ||||||
| return parsed.toString() | ||||||
| } catch { | ||||||
| return url | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Parse a URL that contains /git/{segment1}/{segment2}.git | ||||||
| * Returns the two segments and whether they look like UUIDs. | ||||||
| */ | ||||||
| export function parseGitPathUrl(url: string): null | { | ||||||
| areUuids: boolean | ||||||
| segment1: string | ||||||
| segment2: string | ||||||
| } { | ||||||
| try { | ||||||
| const parsed = new URL(url) | ||||||
| const match = parsed.pathname.match(/^\/git\/([^/]+)\/([^/]+?)\.git$/) | ||||||
| if (!match) return null | ||||||
| const segment1 = match[1] | ||||||
| const segment2 = match[2] | ||||||
| return {areUuids: isUuid(segment1) && isUuid(segment2), segment1, segment2} | ||||||
| } catch { | ||||||
| return null | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Parse a user-facing .git URL to extract team and space names. | ||||||
| * Expected path: /{teamName}/{spaceName}.git (no /git/ prefix) | ||||||
| * Parse a .git URL to extract team and space names. | ||||||
| * Expected path: /{teamName}/{spaceName}.git | ||||||
| */ | ||||||
| export function parseUserFacingUrl(url: string): null | {spaceName: string; teamName: string} { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick (docs): Same issue — the property names in the return type |
||||||
| try { | ||||||
|
|
@@ -69,9 +34,3 @@ export function isValidBranchName(name: string): boolean { | |||||
| return !/\.\.|[~^:?*[\\\u0000-\u001F\u007F]/.test(name) | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Check if a string looks like a UUID (v1-v7, with hyphens). | ||||||
| */ | ||||||
| function isUuid(value: string): boolean { | ||||||
| return /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i.test(value) | ||||||
| } | ||||||
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.
nitpick (code quality): Dead code is suppressed with
/* eslint-disable no-unreachable */at the file level, silencing the linter for the entire file. If the intent is to keep the old implementation for future reference, it would be safer to move it to a comment block or a separate archived file. The current approach is fragile — any genuinely unreachable code added later to this file won't be caught.If the
brv initcommand is being permanently retired (it's now hidden and redirects users), just delete the old body entirely.