Skip to content

Commit 6307ef1

Browse files
Copilotedvilme
andauthored
Resolve remaining merge conflict markers from main merge
Co-authored-by: edvilme <5952839+edvilme@users.noreply.github.com>
1 parent 6f68df1 commit 6307ef1

4 files changed

Lines changed: 46 additions & 198 deletions

File tree

‎src/features/creators/autoFindProjects.ts‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ import { traceInfo } from '../../common/logging';
66
import { normalizePath } from '../../common/utils/pathUtils';
77
import { showErrorMessage, showQuickPickWithButtons, showWarningMessage } from '../../common/window.apis';
88
import { findFiles } from '../../common/workspace.apis';
9-
<<<<<<< HEAD
10-
import { PythonProjectManager, PythonProjectsImpl } from '../../internal.api';
11-
=======
12-
import {
13-
PythonProjectManager,
14-
PythonProjectsImpl,
15-
} from '../projectManager';
16-
import { normalizePath } from '../../common/utils/pathUtils';
17-
>>>>>>> origin/main
9+
import { PythonProjectManager, PythonProjectsImpl } from '../projectManager';
1810

1911
function getUniqueUri(uris: Uri[]): {
2012
label: string;

‎src/features/projectManager.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ export interface InlineScriptProjectRegistrationMarker {
5151
}
5252

5353
export class PythonProjectsImpl implements PythonProject {
54+
private static readonly dependencyFileNames = [
55+
'requirements.txt',
56+
'pyproject.toml',
57+
'requirements.in',
58+
'environment.yml',
59+
] as const;
60+
5461
readonly name: string;
5562
readonly uri: Uri;
5663
readonly description?: string;
@@ -68,6 +75,43 @@ export class PythonProjectsImpl implements PythonProject {
6875
this.tooltip = options?.tooltip ?? uri.fsPath;
6976
this.iconPath = options?.iconPath;
7077
}
78+
79+
/**
80+
* Finds the preferred dependency file at the project root.
81+
* @returns The dependency file URI, or `undefined` when no supported dependency file exists.
82+
*/
83+
async discoverDependencyFiles(): Promise<Uri | undefined> {
84+
let projectType: FileType;
85+
try {
86+
projectType = (await stat(this.uri)).type;
87+
} catch {
88+
return undefined;
89+
}
90+
91+
// A project URI may point directly to a dependency file instead of its parent directory.
92+
if (projectType !== FileType.Directory) {
93+
const fileName = path.posix.basename(this.uri.path);
94+
return projectType === FileType.File &&
95+
PythonProjectsImpl.dependencyFileNames.some((candidate) => candidate === fileName)
96+
? this.uri
97+
: undefined;
98+
}
99+
100+
// Search directory candidates in dependency-file priority order.
101+
for (const fileName of PythonProjectsImpl.dependencyFileNames) {
102+
const candidate = this.uri.with({ path: path.posix.join(this.uri.path, fileName) });
103+
try {
104+
const candidateType = (await stat(candidate)).type;
105+
if (candidateType === FileType.File) {
106+
return candidate;
107+
}
108+
} catch {
109+
// Try the next supported dependency file.
110+
}
111+
}
112+
113+
return undefined;
114+
}
71115
}
72116

73117
type ProjectArray = PythonProject[];

‎src/managers/common/registeredManagers.ts‎

Lines changed: 0 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,6 @@
22
// Licensed under the MIT License.
33

44
import type { Pep440Version } from '@renovatebot/pep440';
5-
<<<<<<< HEAD:src/internal.api.ts
6-
import * as path from 'path';
7-
import {
8-
CancellationError,
9-
Disposable,
10-
Event,
11-
FileType,
12-
LogOutputChannel,
13-
MarkdownString,
14-
RelativePattern,
15-
Uri,
16-
} from 'vscode';
17-
import {
18-
=======
195
import { CancellationError, Disposable, LogOutputChannel, MarkdownString, RelativePattern } from 'vscode';
206
import { PackageVersionLookupNotSupportedError } from '../../publicErrors';
217
import { ISSUES_URL } from '../../common/constants';
@@ -26,7 +12,6 @@ import { EventNames } from '../../common/telemetry/constants';
2612
import { classifyError, isTimeoutErrorType } from '../../common/telemetry/errorClassifier';
2713
import { sendTelemetryEvent } from '../../common/telemetry/sender';
2814
import type {
29-
>>>>>>> origin/main:src/managers/common/registeredManagers.ts
3015
CreateEnvironmentOptions,
3116
CreateEnvironmentScope,
3217
DidChangeEnvironmentEventArgs,
@@ -47,19 +32,7 @@ import type {
4732
RemoveEnvironmentOptions,
4833
ResolveEnvironmentContext,
4934
SetEnvironmentScope,
50-
<<<<<<< HEAD:src/internal.api.ts
51-
} from './api';
52-
import { ISSUES_URL } from './common/constants';
53-
import { CreateEnvironmentNotSupported, RemoveEnvironmentNotSupported } from './common/errors/NotSupportedError';
54-
import { traceWarn } from './common/logging';
55-
import { StopWatch } from './common/stopWatch';
56-
import { EventNames } from './common/telemetry/constants';
57-
import { classifyError, isTimeoutErrorType } from './common/telemetry/errorClassifier';
58-
import { sendTelemetryEvent } from './common/telemetry/sender';
59-
import { stat } from './common/workspace.fs.apis';
60-
=======
6135
} from '../../types';
62-
>>>>>>> origin/main:src/managers/common/registeredManagers.ts
6336

6437
/*
6538
* Runtime wrappers around registered {@link EnvironmentManager} and {@link PackageManager}
@@ -367,164 +340,3 @@ export class InternalPackageManager implements PackageManager {
367340
: `${packageName}==${version}`;
368341
}
369342
}
370-
<<<<<<< HEAD:src/internal.api.ts
371-
372-
export interface PythonProjectManager extends Disposable {
373-
initialize(): void;
374-
create(
375-
name: string,
376-
uri: Uri,
377-
options?: { description?: string; tooltip?: string | MarkdownString; iconPath?: IconPath },
378-
): PythonProject;
379-
add(pyWorkspace: PythonProject | PythonProject[], options?: { persistSettings?: boolean }): Promise<void>;
380-
remove(pyWorkspace: PythonProject | PythonProject[]): void;
381-
getProjects(uris?: Uri[]): ReadonlyArray<PythonProject>;
382-
get(uri: Uri): PythonProject | undefined;
383-
onDidChangeProjects: Event<PythonProject[] | undefined>;
384-
}
385-
386-
export type InlineScriptProjectRegistrationKind = 'created' | 'adopted';
387-
388-
export interface InlineScriptProjectRegistrationMarker {
389-
readonly kind: InlineScriptProjectRegistrationKind;
390-
}
391-
392-
export interface PythonProjectSettings {
393-
path: string;
394-
envManager: string;
395-
packageManager: string;
396-
workspace?: string;
397-
_inlineScriptRegistration?: InlineScriptProjectRegistrationMarker;
398-
}
399-
400-
export class PythonEnvironmentImpl implements PythonEnvironment {
401-
public readonly name: string;
402-
public readonly displayName: string;
403-
public readonly shortDisplayName?: string;
404-
public readonly displayPath: string;
405-
public readonly version: string;
406-
public readonly environmentPath: Uri;
407-
public readonly description?: string;
408-
public readonly tooltip?: string | MarkdownString;
409-
public readonly iconPath?: IconPath;
410-
public readonly execInfo: PythonEnvironmentExecutionInfo;
411-
public readonly sysPrefix: string;
412-
public readonly group?: string | EnvironmentGroupInfo;
413-
public readonly error?: string;
414-
415-
constructor(
416-
public readonly envId: PythonEnvironmentId,
417-
info: PythonEnvironmentInfo,
418-
) {
419-
this.name = info.name;
420-
this.displayName = info.displayName ?? this.name;
421-
this.shortDisplayName = info.shortDisplayName;
422-
this.displayPath = info.displayPath;
423-
this.version = info.version;
424-
this.environmentPath = info.environmentPath;
425-
this.description = info.description;
426-
this.tooltip = info.tooltip;
427-
this.iconPath = info.iconPath;
428-
this.execInfo = info.execInfo;
429-
this.sysPrefix = info.sysPrefix;
430-
this.group = info.group;
431-
this.error = info.error;
432-
}
433-
}
434-
435-
export class PythonPackageImpl implements Package {
436-
public readonly name: string;
437-
public readonly displayName: string;
438-
public readonly version?: string;
439-
public readonly description?: string;
440-
public readonly tooltip?: string | MarkdownString;
441-
public readonly iconPath?: IconPath;
442-
public readonly uris?: readonly Uri[];
443-
444-
public readonly isTransitive?: boolean;
445-
446-
constructor(
447-
public readonly pkgId: PackageId,
448-
info: PackageInfo,
449-
) {
450-
this.name = info.name;
451-
this.displayName = info.displayName ?? this.name;
452-
this.version = info.version;
453-
this.description = info.description;
454-
this.tooltip = info.tooltip;
455-
this.iconPath = info.iconPath;
456-
this.uris = info.uris;
457-
this.isTransitive = info.isTransitive;
458-
}
459-
}
460-
461-
export class PythonProjectsImpl implements PythonProject {
462-
private static readonly dependencyFileNames = [
463-
'requirements.txt',
464-
'pyproject.toml',
465-
'requirements.in',
466-
'environment.yml',
467-
] as const;
468-
469-
name: string;
470-
uri: Uri;
471-
description?: string;
472-
tooltip?: string | MarkdownString;
473-
iconPath?: IconPath;
474-
475-
constructor(
476-
name: string,
477-
uri: Uri,
478-
options?: { description?: string; tooltip?: string | MarkdownString; iconPath?: IconPath },
479-
) {
480-
this.name = name;
481-
this.uri = uri;
482-
this.description = options?.description ?? uri.fsPath;
483-
this.tooltip = options?.tooltip ?? uri.fsPath;
484-
this.iconPath = options?.iconPath;
485-
}
486-
487-
/**
488-
* Finds the preferred dependency file at the project root.
489-
* @returns The dependency file URI, or `undefined` when no supported dependency file exists.
490-
*/
491-
async discoverDependencyFiles(): Promise<Uri | undefined> {
492-
let projectType: FileType;
493-
try {
494-
projectType = (await stat(this.uri)).type;
495-
} catch {
496-
return undefined;
497-
}
498-
499-
// A project URI may point directly to a dependency file instead of its parent directory.
500-
if (projectType !== FileType.Directory) {
501-
const fileName = path.posix.basename(this.uri.path);
502-
return projectType === FileType.File &&
503-
PythonProjectsImpl.dependencyFileNames.some((candidate) => candidate === fileName)
504-
? this.uri
505-
: undefined;
506-
}
507-
508-
// Search directory candidates in dependency-file priority order.
509-
for (const fileName of PythonProjectsImpl.dependencyFileNames) {
510-
const candidate = this.uri.with({ path: path.posix.join(this.uri.path, fileName) });
511-
try {
512-
const candidateType = (await stat(candidate)).type;
513-
if (candidateType === FileType.File) {
514-
return candidate;
515-
}
516-
} catch {
517-
// Try the next supported dependency file.
518-
}
519-
}
520-
521-
return undefined;
522-
}
523-
}
524-
525-
export interface ProjectCreators extends Disposable {
526-
registerPythonProjectCreator(creator: PythonProjectCreator): Disposable;
527-
getProjectCreators(): PythonProjectCreator[];
528-
}
529-
=======
530-
>>>>>>> origin/main:src/managers/common/registeredManagers.ts

‎src/test/features/projectDependencyFiles.unit.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'assert';
22
import * as sinon from 'sinon';
33
import { FileStat, FileType, Uri } from 'vscode';
44
import * as workspaceFs from '../../common/workspace.fs.apis';
5-
import { PythonProjectsImpl } from '../../internal.api';
5+
import { PythonProjectsImpl } from '../../features/projectManager';
66

77
function fileStat(type: FileType): FileStat {
88
return { type, ctime: 0, mtime: 0, size: 0 };

0 commit comments

Comments
 (0)