|
|
@ -85,7 +85,7 @@ class DGitProvider extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async init(input) { |
|
|
|
async init(input) { |
|
|
|
if(isElectron()) { |
|
|
|
if (isElectron()) { |
|
|
|
await this.call('isogit', 'init', { |
|
|
|
await this.call('isogit', 'init', { |
|
|
|
defaultBranch: (input && input.branch) || 'main' |
|
|
|
defaultBranch: (input && input.branch) || 'main' |
|
|
|
}) |
|
|
|
}) |
|
|
@ -314,6 +314,11 @@ class DGitProvider extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async readblob(cmd) { |
|
|
|
async readblob(cmd) { |
|
|
|
|
|
|
|
console.log('readblob', cmd) |
|
|
|
|
|
|
|
if (isElectron()) { |
|
|
|
|
|
|
|
const readBlobResult = await this.call('isogit', 'readblob', cmd) |
|
|
|
|
|
|
|
console.log('readblob', readBlobResult) |
|
|
|
|
|
|
|
} |
|
|
|
const readBlobResult = await git.readBlob({ |
|
|
|
const readBlobResult = await git.readBlob({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...await this.getGitConfig(), |
|
|
|
...cmd |
|
|
|
...cmd |
|
|
@ -339,10 +344,18 @@ class DGitProvider extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async addremote(input) { |
|
|
|
async addremote(input) { |
|
|
|
|
|
|
|
if (isElectron()) { |
|
|
|
|
|
|
|
await this.call('isogit', 'addremote', { url: input.url, remote: input.remote }) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
await git.addRemote({ ...await this.getGitConfig(), url: input.url, remote: input.remote }) |
|
|
|
await git.addRemote({ ...await this.getGitConfig(), url: input.url, remote: input.remote }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async delremote(input) { |
|
|
|
async delremote(input) { |
|
|
|
|
|
|
|
if (isElectron()) { |
|
|
|
|
|
|
|
await this.call('isogit', 'delremote', { remote: input.remote }) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
await git.deleteRemote({ ...await this.getGitConfig(), remote: input.remote }) |
|
|
|
await git.deleteRemote({ ...await this.getGitConfig(), remote: input.remote }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -351,27 +364,45 @@ class DGitProvider extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async clone(input, workspaceName, workspaceExists = false) { |
|
|
|
async clone(input, workspaceName, workspaceExists = false) { |
|
|
|
const permission = await this.askUserPermission('clone', 'Import multiple files into your workspaces.') |
|
|
|
|
|
|
|
if (!permission) return false |
|
|
|
|
|
|
|
if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.') |
|
|
|
|
|
|
|
if (!workspaceExists) await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) |
|
|
|
|
|
|
|
const cmd = { |
|
|
|
|
|
|
|
url: input.url, |
|
|
|
|
|
|
|
singleBranch: input.singleBranch, |
|
|
|
|
|
|
|
ref: input.branch, |
|
|
|
|
|
|
|
depth: input.depth || 10, |
|
|
|
|
|
|
|
...await this.parseInput(input), |
|
|
|
|
|
|
|
...await this.getGitConfig() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await git.clone(cmd) |
|
|
|
if (isElectron()) { |
|
|
|
if (!workspaceExists) { |
|
|
|
const folder = await this.call('isogit', 'openFolder') |
|
|
|
setTimeout(async () => { |
|
|
|
if (!folder) return false |
|
|
|
await this.call('fileManager', 'refresh') |
|
|
|
console.log('folder', folder) |
|
|
|
}, 1000) |
|
|
|
const cmd = { |
|
|
|
|
|
|
|
url: input.url, |
|
|
|
|
|
|
|
singleBranch: input.singleBranch, |
|
|
|
|
|
|
|
ref: input.branch, |
|
|
|
|
|
|
|
depth: input.depth || 10, |
|
|
|
|
|
|
|
dir: folder, |
|
|
|
|
|
|
|
input |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const result = await this.call('isogit', 'clone', cmd) |
|
|
|
|
|
|
|
await this.call('fs', 'openWindow', folder) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
const permission = await this.askUserPermission('clone', 'Import multiple files into your workspaces.') |
|
|
|
|
|
|
|
if (!permission) return false |
|
|
|
|
|
|
|
if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.') |
|
|
|
|
|
|
|
if (!workspaceExists) await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true) |
|
|
|
|
|
|
|
const cmd = { |
|
|
|
|
|
|
|
url: input.url, |
|
|
|
|
|
|
|
singleBranch: input.singleBranch, |
|
|
|
|
|
|
|
ref: input.branch, |
|
|
|
|
|
|
|
depth: input.depth || 10, |
|
|
|
|
|
|
|
...await this.parseInput(input), |
|
|
|
|
|
|
|
...await this.getGitConfig() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const result = await git.clone(cmd) |
|
|
|
|
|
|
|
if (!workspaceExists) { |
|
|
|
|
|
|
|
setTimeout(async () => { |
|
|
|
|
|
|
|
await this.call('fileManager', 'refresh') |
|
|
|
|
|
|
|
}, 1000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.emit('clone') |
|
|
|
|
|
|
|
return result |
|
|
|
} |
|
|
|
} |
|
|
|
this.emit('clone') |
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async push(input) { |
|
|
|
async push(input) { |
|
|
@ -384,17 +415,22 @@ class DGitProvider extends Plugin { |
|
|
|
name: input.name, |
|
|
|
name: input.name, |
|
|
|
email: input.email |
|
|
|
email: input.email |
|
|
|
}, |
|
|
|
}, |
|
|
|
...await this.parseInput(input), |
|
|
|
input |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (isElectron()) { |
|
|
|
if (isElectron()) { |
|
|
|
return await this.call('isogit', 'push', cmd) |
|
|
|
return await this.call('isogit', 'push', cmd) |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
return await git.push({ |
|
|
|
cmd = { |
|
|
|
...await this.getGitConfig(), |
|
|
|
...cmd, |
|
|
|
...cmd |
|
|
|
...await this.parseInput(input), |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
return await git.push({ |
|
|
|
|
|
|
|
...await this.getGitConfig(), |
|
|
|
|
|
|
|
...cmd |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async pull(input) { |
|
|
|
async pull(input) { |
|
|
@ -406,14 +442,17 @@ class DGitProvider extends Plugin { |
|
|
|
email: input.email |
|
|
|
email: input.email |
|
|
|
}, |
|
|
|
}, |
|
|
|
remote: input.remote, |
|
|
|
remote: input.remote, |
|
|
|
...await this.parseInput(input), |
|
|
|
input |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
let result |
|
|
|
let result |
|
|
|
if (isElectron()) { |
|
|
|
if (isElectron()) { |
|
|
|
result = await this.call('isogit', 'pull', cmd) |
|
|
|
result = await this.call('isogit', 'pull', cmd) |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
cmd = { |
|
|
|
|
|
|
|
...cmd, |
|
|
|
|
|
|
|
...await this.parseInput(input), |
|
|
|
|
|
|
|
} |
|
|
|
result = await git.pull({ |
|
|
|
result = await git.pull({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...await this.getGitConfig(), |
|
|
|
...cmd |
|
|
|
...cmd |
|
|
@ -434,12 +473,16 @@ class DGitProvider extends Plugin { |
|
|
|
email: input.email |
|
|
|
email: input.email |
|
|
|
}, |
|
|
|
}, |
|
|
|
remote: input.remote, |
|
|
|
remote: input.remote, |
|
|
|
...await this.parseInput(input), |
|
|
|
input |
|
|
|
} |
|
|
|
} |
|
|
|
let result |
|
|
|
let result |
|
|
|
if (isElectron()) { |
|
|
|
if (isElectron()) { |
|
|
|
result = await this.call('isogit', 'fetch', cmd) |
|
|
|
result = await this.call('isogit', 'fetch', cmd) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
cmd = { |
|
|
|
|
|
|
|
...cmd, |
|
|
|
|
|
|
|
...await this.parseInput(input), |
|
|
|
|
|
|
|
} |
|
|
|
result = await git.fetch({ |
|
|
|
result = await git.fetch({ |
|
|
|
...await this.getGitConfig(), |
|
|
|
...await this.getGitConfig(), |
|
|
|
...cmd |
|
|
|
...cmd |
|
|
|