Skip to content

Commit f94347b

Browse files
committed
Component create from Git fails if a devfile exists in git repo #3386
Fixes: #3386 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent 4f3f138 commit f94347b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/webview/create-component/createComponentLoader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from '../common-ext/createComponentHelpers';
3030
import { loadWebviewHtml, validateGitURL } from '../common-ext/utils';
3131
import { Devfile, DevfileRegistry, TemplateProjectIdentifier } from '../common/devfile';
32+
import { DevfileV1 } from '../../util/devfileV1Type';
3233

3334
interface CloneProcess {
3435
status: boolean;
@@ -444,7 +445,7 @@ export default class CreateComponentLoader {
444445
try {
445446
const devFileV1Path = path.join(uri.fsPath, 'devfile.yaml');
446447
const file = await fs.readFile(devFileV1Path, 'utf8');
447-
const devfileV1 = JSYAML.load(file.toString());
448+
const devfileV1 = JSYAML.load(file.toString()) as DevfileV1;
448449
await fs.unlink(devFileV1Path);
449450
analyzeRes = await OdoImpl.Instance.analyze(uri.fsPath);
450451
compDescriptions = getCompDescription(analyzeRes);
@@ -475,7 +476,7 @@ export default class CreateComponentLoader {
475476
});
476477
const devfileRegistry: DevfileRegistry[] = getDevfileRegistries();
477478
const allDevfiles: Devfile[] = devfileRegistry.flatMap((registry) => registry.devfiles);
478-
const devfile: Devfile =
479+
const devfile: Devfile | undefined =
479480
compDescriptions.length !== 0
480481
? allDevfiles.find(
481482
(devfile) => devfile.name === compDescriptions[0].displayName,

src/webview/create-component/pages/fromExistingGitRepo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ export function FromExistingGitRepo({ setCurrentView }) {
453453
setCurrentPage('fromGitRepo');
454454
}}
455455
createComponent={createComponentFromGitRepo}
456-
devfile={recommendedDevfile.isDevfileExistsInRepo ? undefined : selectedDevfile ? selectedDevfile : recommendedDevfile.devfile}
456+
devfile={recommendedDevfile.isDevfileExistsInRepo ? recommendedDevfile.devfile : selectedDevfile ? selectedDevfile : recommendedDevfile.devfile}
457457
initialComponentName={gitURL.url.substring(gitURL.url.lastIndexOf('/') + 1)}
458458
/>
459459
);

0 commit comments

Comments
 (0)