Skip to content

Commit

Permalink
Component create from Git fails if a devfile exists in git repo #3386
Browse files Browse the repository at this point in the history
Fixes: #3386

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
  • Loading branch information
vrubezhny committed Oct 2, 2023
1 parent 4f3f138 commit f94347b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/webview/create-component/createComponentLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
} from '../common-ext/createComponentHelpers';
import { loadWebviewHtml, validateGitURL } from '../common-ext/utils';
import { Devfile, DevfileRegistry, TemplateProjectIdentifier } from '../common/devfile';
import { DevfileV1 } from '../../util/devfileV1Type';

interface CloneProcess {
status: boolean;
Expand Down Expand Up @@ -444,7 +445,7 @@ export default class CreateComponentLoader {
try {
const devFileV1Path = path.join(uri.fsPath, 'devfile.yaml');
const file = await fs.readFile(devFileV1Path, 'utf8');
const devfileV1 = JSYAML.load(file.toString());
const devfileV1 = JSYAML.load(file.toString()) as DevfileV1;

Check warning on line 448 in src/webview/create-component/createComponentLoader.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/create-component/createComponentLoader.ts#L448

Added line #L448 was not covered by tests
await fs.unlink(devFileV1Path);
analyzeRes = await OdoImpl.Instance.analyze(uri.fsPath);
compDescriptions = getCompDescription(analyzeRes);
Expand Down Expand Up @@ -475,7 +476,7 @@ export default class CreateComponentLoader {
});
const devfileRegistry: DevfileRegistry[] = getDevfileRegistries();
const allDevfiles: Devfile[] = devfileRegistry.flatMap((registry) => registry.devfiles);
const devfile: Devfile =
const devfile: Devfile | undefined =

Check warning on line 479 in src/webview/create-component/createComponentLoader.ts

View check run for this annotation

Codecov / codecov/patch

src/webview/create-component/createComponentLoader.ts#L479

Added line #L479 was not covered by tests
compDescriptions.length !== 0
? allDevfiles.find(
(devfile) => devfile.name === compDescriptions[0].displayName,
Expand Down
2 changes: 1 addition & 1 deletion src/webview/create-component/pages/fromExistingGitRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ export function FromExistingGitRepo({ setCurrentView }) {
setCurrentPage('fromGitRepo');
}}
createComponent={createComponentFromGitRepo}
devfile={recommendedDevfile.isDevfileExistsInRepo ? undefined : selectedDevfile ? selectedDevfile : recommendedDevfile.devfile}
devfile={recommendedDevfile.isDevfileExistsInRepo ? recommendedDevfile.devfile : selectedDevfile ? selectedDevfile : recommendedDevfile.devfile}
initialComponentName={gitURL.url.substring(gitURL.url.lastIndexOf('/') + 1)}
/>
);
Expand Down

0 comments on commit f94347b

Please sign in to comment.