fixes for git

rdesktop2
filip mertens 1 year ago
parent e5ec564b1e
commit f927730171
  1. 17
      apps/remix-ide/src/app/files/dgitProvider.js
  2. 5
      apps/remix-ide/src/remixAppManager.js
  3. 24
      apps/remixdesktop/src/plugins/fsPlugin.ts
  4. 23
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  5. 2
      apps/remixdesktop/src/tools/git.ts
  6. 4
      libs/remix-ui/search/src/lib/context/context.tsx
  7. 2
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -21,7 +21,7 @@ const profile = {
description: 'Decentralized git provider',
icon: 'assets/img/fileManager.webp',
version: '0.0.1',
methods: ['init', 'localStorageUsed', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem'],
methods: ['init', 'localStorageUsed', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'reset', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem'],
kind: 'file-system'
}
class DGitProvider extends Plugin {
@ -144,6 +144,21 @@ class DGitProvider extends Plugin {
}
}
async reset(cmd) {
console.log('rm', cmd)
if (isElectron()) {
await this.call('isogit', 'reset', cmd)
} else {
await git.resetIndex({
...await this.getGitConfig(),
...cmd
})
this.emit('rm')
}
}
async checkout(cmd, refresh = true) {
if (isElectron()) {

@ -14,9 +14,9 @@ let requiredModules = [ // services + layout views + system views
'vm-shanghai',
'compileAndRun', 'search', 'recorder', 'fileDecorator', 'codeParser', 'codeFormatter', 'solidityumlgen', 'contractflattener', 'solidity-script']
if(isElectron()) {
if (isElectron()) {
requiredModules = [...requiredModules, 'fs', 'electronTemplates', 'isogit', 'remix-templates', 'electronconfig']
}
}
// dependentModules shouldn't be manually activated (e.g hardhat is activated by remixd)
@ -183,6 +183,7 @@ export class RemixAppManager extends PluginManager {
}
return plugins.map(plugin => {
if (plugin.name === 'dgit') { plugin.url = 'https://dgit4-76cc9.web.app/' }
if (plugin.name === testPluginName) plugin.url = testPluginUrl
return new IframePlugin(plugin)
})

@ -19,6 +19,10 @@ const convertPathToPosix = (pathName: string): string => {
return pathName.split(path.sep).join(path.posix.sep)
}
const getBaseName = (pathName: string): string => {
return path.basename(pathName)
}
export class FSPlugin extends ElectronBasePlugin {
clients: FSPluginClient[] = []
@ -81,7 +85,7 @@ const clientProfile: Profile = {
name: 'fs',
displayName: 'fs',
description: 'fs',
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'getRecentFolders', 'removeRecentFolder', 'glob', 'openWindow', 'selectFolder']
methods: ['readdir', 'readFile', 'writeFile', 'mkdir', 'rmdir', 'unlink', 'rename', 'stat', 'lstat', 'exists', 'currentPath', 'watch', 'closeWatch', 'setWorkingDir', 'openFolder', 'openFolderInSameWindow', 'getRecentFolders', 'removeRecentFolder', 'glob', 'openWindow', 'selectFolder']
}
class FSPluginClient extends ElectronBasePluginClient {
@ -341,6 +345,21 @@ class FSPluginClient extends ElectronBasePluginClient {
}
path = dirs && dirs.length && dirs[0] ? dirs[0] : path
if (!path) return
await this.updateRecentFolders(path)
await this.updateOpenedFolders(path)
this.openWindow(path)
}
async openFolderInSameWindow(path?: string): Promise<void> {
let dirs: string[] | undefined
if (!path) {
dirs = dialog.showOpenDialogSync(this.window, {
properties: ['openDirectory', 'createDirectory', "showHiddenFiles"]
})
}
path = dirs && dirs.length && dirs[0] ? dirs[0] : path
if (!path) return
this.workingDir = path
await this.updateRecentFolders(path)
await this.updateOpenedFolders(path)
@ -355,9 +374,10 @@ class FSPluginClient extends ElectronBasePluginClient {
this.workingDir = path
await this.updateRecentFolders(path)
await this.updateOpenedFolders(path)
this.window.setTitle(this.workingDir)
this.window.setTitle(getBaseName(this.workingDir))
this.watch()
this.emit('workingDirChanged', path)
await this.call('fileManager', 'closeAllFiles')
}
fixPath(path: string): string {

@ -46,11 +46,11 @@ const clientProfile: Profile = {
name: 'isogit',
displayName: 'isogit',
description: 'isogit plugin',
methods: ['init', 'localStorageUsed', 'version', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder']
methods: ['init', 'localStorageUsed', 'version', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'reset', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder']
}
class IsoGitPluginClient extends ElectronBasePluginClient {
workingDir: string = '/Volumes/bunsen/code/empty/'
workingDir: string = ''
gitIsInstalled: boolean = false
constructor(webContentsId: number, profile: Profile) {
super(webContentsId, profile)
@ -81,6 +81,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async status(cmd: any) {
console.log('status', cmd)
if(this.workingDir === ''){
return []
}
if(this.gitIsInstalled){
const status = await gitProxy.status(this.workingDir)
return status
@ -104,6 +108,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
*/
if(this.workingDir === ''){
return []
}
console.log('log')
const log = await git.log({
...await this.getGitConfig(),
@ -133,6 +141,17 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return rm
}
async reset(cmd: any){
console.log('reset', cmd)
const reset = await git.resetIndex({
...await this.getGitConfig(),
...cmd
})
console.log('RESET', reset)
return reset
}
async commit(cmd: any) {
console.log('commit')
const commit = await git.commit({

@ -16,7 +16,7 @@ const statusTransFormMatrix = (status: string) => {
case ' M':
return [1, 2, 0]
case ' D':
return [0, 2, 0]
return [1, 0, 1]
case 'D ':
return [1, 0, 0]
case 'AM':

@ -327,6 +327,10 @@ export const SearchProvider = ({
setFiles(await getDirectory('/', plugin))
})
plugin.on('fs', 'workingDirChanged', async () => {
setFiles(await getDirectory('/', plugin))
})
plugin.on('fileManager', 'fileAdded', async file => {
setFiles(await getDirectory('/', plugin))
await reloadStateForFile(file)

@ -775,7 +775,7 @@ export const checkoutRemoteBranch = async (branch: string, remote: string) => {
}
export const openElectronFolder = async (path: string) => {
await plugin.call('fs', 'openFolder', path)
await plugin.call('fs', 'openFolderInSameWindow', path)
}
export const getElectronRecentFolders = async () => {

Loading…
Cancel
Save