Skip to content

Commit 289fdb9

Browse files
committed
chore: git clone working
1 parent 23b05e9 commit 289fdb9

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/assets/new-project/assets/js/new-git-project.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function desktopInit() {
7474
return;
7575
}
7676
const {clonePath, error} = await newProjectExtension.getGitCloneDir(newPath, websiteURLInput.value);
77-
locationInput.fullPath = clonePath;
77+
locationInput.clonePath = clonePath;
7878
locationInput.value = window.top.Phoenix.fs.getTauriPlatformPath(clonePath);
7979
locationInput.error = error;
8080
locationInput.originalPath = newPath;
@@ -91,7 +91,7 @@ function desktopInit() {
9191

9292
function _createProjectClicked() {
9393
localStorage.setItem(LAST_GIT_CLONE_BASE_DIR, locationInput.originalPath);
94-
//newProjectExtension.gitClone(websiteURLInput.value, locationInput.value);
94+
newProjectExtension.gitClone(websiteURLInput.value, locationInput.clonePath);
9595
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "git.Click", "create");
9696
newProjectExtension.closeDialogue();
9797
}

src/extensionsIntegrated/Phoenix/new-project.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
*/
2020

21-
/*global path*/
21+
/*global path, jsPromise*/
2222

2323
define(function (require, exports, module) {
2424
const Dialogs = require("widgets/Dialogs"),
@@ -388,6 +388,25 @@ define(function (require, exports, module) {
388388
});
389389
}
390390

391+
async function gitClone(url, cloneDIR) {
392+
try{
393+
const cloneFolderExists = await _dirExists(cloneDIR);
394+
if(!cloneFolderExists) {
395+
await Phoenix.VFS.ensureExistsDirAsync(cloneDIR);
396+
}
397+
await jsPromise(ProjectManager.openProject(cloneDIR));
398+
CommandManager.execute("git-clone-url", url, cloneDIR );
399+
} catch (e) {
400+
setTimeout(async ()=>{
401+
// we need this timeout as when user clicks clone in new project dialog, it will immediately
402+
// close the error dialog too as it dismisses itself.
403+
showErrorDialogue(Strings.ERROR_CLONING_TITLE, e.message || e);
404+
}, 100);
405+
console.error("git clone failed: ", url, cloneDIR, e);
406+
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "gitClone", "fail");
407+
}
408+
}
409+
391410
function _getGitFolderName(gitURL) {
392411
if (typeof gitURL !== 'string' || !gitURL.trim()) {
393412
return "";
@@ -460,6 +479,7 @@ define(function (require, exports, module) {
460479
exports.showFolderSelect = showFolderSelect;
461480
exports.showErrorDialogue = showErrorDialogue;
462481
exports.getGitCloneDir = getGitCloneDir;
482+
exports.gitClone = gitClone;
463483
exports.setupExploreProject = defaultProjects.setupExploreProject;
464484
exports.setupStartupProject = defaultProjects.setupStartupProject;
465485
exports.alreadyExists = window.Phoenix.VFS.existsAsync;

src/nls/root/strings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ define({
11981198
"ERROR_GIT_URL_INVALID": "Please enter a valid Git clone URL.",
11991199
"ERROR_GIT_FOLDER_NOT_EMPTY": "The Selected folder cannot be used for Git clone as it is not empty or is unreadable.",
12001200
"ERROR_GIT_FOLDER_NOT_EXIST": "The Selected folder cannot be used for Git clone as it does not exist.",
1201+
"ERROR_CLONING_TITLE": "Git clone Failed",
12011202
"DOWNLOADING": "Downloading...",
12021203
"DOWNLOADING_FILE": "Downloading {0}...",
12031204
"EXTRACTING_FILES_PROGRESS": "Extracting {0} of {1} files.",

0 commit comments

Comments
 (0)