Refactor collection handling for mobile remote connect
- Replace chained array transforms with explicit loops across mobile and server paths - Tighten provider, git, and orchestration parsing while preserving behavior - Improve remote-connect UI data shaping and thread activity filtering
This commit is contained in:
1 parent
7793bd6de7
commit
90fea7bb2f
54 files changed
+766
-544
No files matched your search
@@ -208,10 +208,13 @@ function parseRepositorySpecifier(repository: string): {
|
||||
readonly project: string | null;
|
||||
readonly name: string;
|
||||
} {
|
||||
const parts = repository
|
||||
.split("/")
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => part.length > 0);
|
||||
const parts: Array<string> = [];
|
||||
for (const part of repository.split("/")) {
|
||||
const trimmed = part.trim();
|
||||
if (trimmed.length > 0) {
|
||||
parts.push(trimmed);
|
||||
}
|
||||
}
|
||||
return {
|
||||
project: parts.length > 1 ? (parts.at(-2) ?? null) : null,
|
||||
name: parts.at(-1) ?? repository.trim(),
|
||||
|
||||
@@ -247,10 +247,13 @@ function parseRepositoryPath(repository: string): {
|
||||
readonly namespacePath: string | null;
|
||||
readonly projectPath: string;
|
||||
} {
|
||||
const parts = repository
|
||||
.split("/")
|
||||
.map((part) => part.trim())
|
||||
.filter((part) => part.length > 0);
|
||||
const parts: Array<string> = [];
|
||||
for (const part of repository.split("/")) {
|
||||
const trimmed = part.trim();
|
||||
if (trimmed.length > 0) {
|
||||
parts.push(trimmed);
|
||||
}
|
||||
}
|
||||
const projectPath = parts.at(-1) ?? repository.trim();
|
||||
const namespacePath = parts.length > 1 ? parts.slice(0, -1).join("/") : null;
|
||||
return { namespacePath, projectPath };
|
||||
|
||||
@@ -96,15 +96,24 @@ export function unknownAuth(detail?: string): SourceControlProviderAuth {
|
||||
}
|
||||
|
||||
export function combinedAuthOutput(input: SourceControlAuthProbeInput): string {
|
||||
return [input.stdout, input.stderr].filter((entry) => entry.trim().length > 0).join("\n");
|
||||
const parts: string[] = [];
|
||||
for (const entry of [input.stdout, input.stderr]) {
|
||||
if (entry.trim().length > 0) {
|
||||
parts.push(entry);
|
||||
}
|
||||
}
|
||||
return parts.join("\n");
|
||||
}
|
||||
|
||||
function sanitizedAuthLines(text: string): ReadonlyArray<string> {
|
||||
return text
|
||||
.split(/\r?\n/)
|
||||
.map((entry) => entry.trim())
|
||||
.filter((entry) => entry.length > 0)
|
||||
.filter((entry) => !/^[-\s]*token(?:\s+scopes?)?:/iu.test(entry));
|
||||
const lines: string[] = [];
|
||||
for (const entry of text.split(/\r?\n/)) {
|
||||
const line = entry.trim();
|
||||
if (line.length === 0) continue;
|
||||
if (/^[-\s]*token(?:\s+scopes?)?:/iu.test(line)) continue;
|
||||
lines.push(line);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function firstSafeAuthLine(text: string): string | undefined {
|
||||
|
||||
@@ -92,18 +92,17 @@ function selectProviderContext(
|
||||
readonly url: string;
|
||||
}>,
|
||||
): SourceControlProvider.SourceControlProviderContext | null {
|
||||
const candidates = remotes
|
||||
.map((remote) => {
|
||||
const provider = detectSourceControlProviderFromRemoteUrl(remote.url);
|
||||
return provider
|
||||
? {
|
||||
provider,
|
||||
remoteName: remote.name,
|
||||
remoteUrl: remote.url,
|
||||
}
|
||||
: null;
|
||||
})
|
||||
.filter((value): value is SourceControlProvider.SourceControlProviderContext => value !== null);
|
||||
const candidates: Array<SourceControlProvider.SourceControlProviderContext> = [];
|
||||
for (const remote of remotes) {
|
||||
const provider = detectSourceControlProviderFromRemoteUrl(remote.url);
|
||||
if (provider) {
|
||||
candidates.push({
|
||||
provider,
|
||||
remoteName: remote.name,
|
||||
remoteUrl: remote.url,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
candidates.find((candidate) => candidate.remoteName === "origin") ??
|
||||
|
||||
Reference in new issue
Block a user