fixes for git

LianaHus-patch-7
filip mertens 11 months ago
parent 3cd0e29e7c
commit aca0db73ae
  1. 4
      apps/remixdesktop/src/plugins/fsPlugin.ts
  2. 72
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  3. 3
      apps/remixdesktop/src/plugins/ripgrepPlugin.ts
  4. 4
      apps/remixdesktop/src/plugins/xtermPlugin.ts
  5. 6
      apps/remixdesktop/src/tools/git.ts
  6. 4
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  7. 6
      libs/remix-ui/xterm/src/lib/components/remix-ui-xterminals.tsx

@ -114,7 +114,9 @@ class FSPluginClient extends ElectronBasePluginClient {
// best for non recursive
async readdir(path: string): Promise<string[]> {
if (this.workingDir === '') throw new Error('workingDir is not set')
if (this.workingDir === '') return new Promise((resolve, reject) => reject({
message: 'no working dir has been set'
}))
// call node fs.readdir
if (!path) return []
const startTime = Date.now()

@ -59,6 +59,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
this.workingDir = path
this.gitIsInstalled = await gitProxy.version() ? true : false
})
this.workingDir = await this.call('fs' as any, 'getWorkingDir')
this.gitIsInstalled = await gitProxy.version() ? true : false
})
}
@ -76,6 +77,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async status(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.workingDir === '') {
return []
@ -117,6 +122,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async add(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const add = await git.add({
...await this.getGitConfig(),
...cmd
@ -127,6 +136,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async rm(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const rm = await git.remove({
...await this.getGitConfig(),
...cmd
@ -137,6 +150,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async reset(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const reset = await git.resetIndex({
...await this.getGitConfig(),
...cmd
@ -147,6 +164,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async commit(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
const status = await gitProxy.commit(this.workingDir, cmd.message)
@ -162,6 +182,14 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async init(input: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
const status = await gitProxy.init(this.workingDir)
return status
}
await git.init({
...await this.getGitConfig(),
defaultBranch: (input && input.branch) || 'main'
@ -169,7 +197,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async branch(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
return null
}
const branch = await git.branch({
...await this.getGitConfig(),
...cmd
@ -179,7 +209,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async lsfiles(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
return []
}
const lsfiles = await git.listFiles({
...await this.getGitConfig(),
...cmd
@ -188,6 +220,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async resolveref(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
return null
}
const resolveref = await git.resolveRef({
...await this.getGitConfig(),
@ -200,6 +235,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async readblob(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const readblob = await git.readBlob({
...await this.getGitConfig(),
...cmd
@ -210,6 +249,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async checkout(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const checkout = await git.checkout({
...await this.getGitConfig(),
...cmd
@ -220,7 +263,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async push(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
await gitProxy.push(this.workingDir, cmd.remote, cmd.ref, cmd.remoteRef, cmd.force)
@ -239,6 +284,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async pull(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
await gitProxy.pull(this.workingDir, cmd.remote, cmd.ref, cmd.remoteRef)
@ -257,6 +306,10 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async fetch(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
await gitProxy.fetch(this.workingDir, cmd.remote, cmd.remoteRef)
@ -274,7 +327,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async clone(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
try{
@ -322,12 +377,18 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
remotes = async () => {
if (!this.workingDir || this.workingDir === '') {
return []
}
let remotes = []
remotes = await git.listRemotes({ ...await this.getGitConfig() })
return remotes
}
async currentbranch() {
if (!this.workingDir || this.workingDir === '') {
return ''
}
try {
const defaultConfig = await this.getGitConfig()
const name = await git.currentBranch(defaultConfig)
@ -340,6 +401,9 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
async branches() {
if (!this.workingDir || this.workingDir === '') {
return []
}
try {
let cmd: any = { ...await this.getGitConfig() }
const remotes = await this.remotes()

@ -50,10 +50,11 @@ export class RipgrepPluginClient extends ElectronBasePluginClient {
constructor(webContentsId: number, profile: Profile) {
super(webContentsId, profile)
this.onload(() => {
this.onload(async () => {
this.on('fs' as any, 'workingDirChanged', async (path: string) => {
this.workingDir = path
})
this.workingDir = await this.call('fs' as any, 'getWorkingDir')
})
}

@ -106,11 +106,13 @@ class XtermPluginClient extends ElectronBasePluginClient {
workingDir: string = ''
constructor(webContentsId: number, profile: Profile) {
super(webContentsId, profile)
this.onload(() => {
this.onload(async () => {
this.emit('loaded')
this.on('fs' as any, 'workingDirChanged', async (path: string) => {
this.workingDir = path
})
this.workingDir = await this.call('fs' as any, 'getWorkingDir')
console.log('workingDir', this.workingDir)
})
}

@ -57,12 +57,16 @@ export const gitProxy = {
async commit(path: string, message: string) {
await execAsync(`git commit -m ${message}`, { cwd: path });
await execAsync(`git commit -m '${message}'`, { cwd: path });
const { stdout, stderr } = await execAsync(`git rev-parse HEAD`, { cwd: path });
return stdout;
},
async init(path: string) {
await execAsync(`git init`, { cwd: path });
},
status: async (path: string) => {
const result = await execAsync('git status --porcelain -uall', { cwd: path })

@ -86,6 +86,10 @@ export const setPlugin = (filePanelPlugin, reducerDispatch) => {
await checkGit()
}
})
plugin.on('fs', 'workingDirChanged', async (path: string) => {
await checkGit()
})
checkGit()
getGitConfig()
}

@ -69,6 +69,12 @@ export const RemixUiXterminals = (props: RemixUiXterminalsProps) => {
setTerminalsEnabled(true)
})
const workingDir = await plugin.call('fs', 'getWorkingDir')
if(workingDir && workingDir !== '') {
setTerminalsEnabled(true)
setWorkingDir(workingDir)
}
plugin.on('theme', 'themeChanged', async (theme) => {
handleThemeChange(theme)
})

Loading…
Cancel
Save