Skip to content

Commit 0fdcb8b

Browse files
committed
Handle importing git repos that already have a Devfile
Fixes #3104 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent 7c53b4e commit 0fdcb8b

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

src/webview/create-component/createComponentLoader.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ export default class CreateComponentLoader {
235235
action: 'cloneFailed',
236236
});
237237
} else {
238+
void CreateComponentLoader.panel.webview.postMessage({
239+
action: 'devfileExists',
240+
data: await isDevfileExists(tmpFolder),
241+
});
238242
CreateComponentLoader.getRecommendedDevfile(tmpFolder);
239243
}
240244
break;
@@ -283,11 +287,13 @@ export default class CreateComponentLoader {
283287
await fse.copy(tmpFolder.fsPath, componentFolder);
284288
}
285289
const devfileType = getDevfileType(message.data.devfileDisplayName);
286-
await OdoImpl.Instance.createComponentFromLocation(
287-
devfileType,
288-
componentName,
289-
Uri.file(componentFolder),
290-
);
290+
if (!await isDevfileExists(Uri.file(componentFolder))) {
291+
await OdoImpl.Instance.createComponentFromLocation(
292+
devfileType,
293+
componentName,
294+
Uri.file(componentFolder),
295+
);
296+
}
291297
await sendTelemetry('newComponentCreated', {
292298
strategy,
293299
component_type: devfileType,

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
AccordionDetails,
99
AccordionSummary,
1010
Alert,
11+
Box,
1112
Button,
1213
CircularProgress,
1314
Divider,
@@ -331,17 +332,21 @@ export function FromExistingGitRepo({ setCurrentView }) {
331332
? 'Selected Devfile'
332333
: 'Recommended Devfile'}
333334
</Typography>
334-
<DevfileRecommendationInfo />
335+
{recommendedDevfile.isDevfileExistsInRepo ? (
336+
<Alert severity="info">
337+
The Devfile that exists in the repo will be used
338+
</Alert>
339+
) : (
340+
<DevfileRecommendationInfo />
341+
)}
335342
</Stack>
336-
{!recommendedDevfile.noRecommendation && (
337-
<DevfileListItem
338-
devfile={
339-
selectedDevfile
340-
? selectedDevfile
341-
: recommendedDevfile.devfile
342-
}
343-
/>
344-
)}
343+
<DevfileListItem
344+
devfile={
345+
selectedDevfile
346+
? selectedDevfile
347+
: recommendedDevfile.devfile
348+
}
349+
/>
345350
<Stack
346351
direction="row"
347352
justifyContent="flex-end"
@@ -369,15 +374,17 @@ export function FromExistingGitRepo({ setCurrentView }) {
369374
>
370375
BACK
371376
</Button>
372-
<Button
373-
variant="contained"
374-
onClick={() => {
375-
setSelectedDevfile(undefined);
376-
setCurrentPage('selectDifferentDevfile');
377-
}}
378-
>
379-
SELECT A DIFFERENT DEVFILE
380-
</Button>
377+
{!recommendedDevfile.isDevfileExistsInRepo && (
378+
<Button
379+
variant="contained"
380+
onClick={() => {
381+
setSelectedDevfile(undefined);
382+
setCurrentPage('selectDifferentDevfile');
383+
}}
384+
>
385+
SELECT A DIFFERENT DEVFILE
386+
</Button>
387+
)}
381388
<Button
382389
variant="contained"
383390
onClick={() => {

0 commit comments

Comments
 (0)