pull/5370/head
bunsenstraat 5 months ago
parent 469682896a
commit 4e626abf07
  1. 99
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 2
      apps/remixdesktop/package.json
  3. 3
      apps/remixdesktop/src/main.ts
  4. 3
      apps/remixdesktop/src/plugins/appUpdater.ts
  5. 1
      apps/remixdesktop/src/plugins/fsPlugin.ts
  6. 242
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  7. 9
      apps/remixdesktop/src/preload.ts
  8. 52
      apps/remixdesktop/src/tools/git.ts
  9. 9
      apps/remixdesktop/src/types/index.ts
  10. 24
      apps/remixdesktop/tsconfig.json
  11. 3
      libs/remix-api/src/index.ts
  12. 5
      libs/remix-api/src/lib/plugins/fileSystem-api.ts
  13. 11
      libs/remix-api/src/lib/plugins/fs-api.ts
  14. 43
      libs/remix-api/src/lib/plugins/git-api.ts
  15. 10
      libs/remix-api/src/lib/plugins/terminal-api.ts
  16. 8
      libs/remix-api/src/lib/remix-api.ts
  17. 189
      libs/remix-api/src/lib/types/git.ts
  18. 1
      libs/remix-git/index.ts
  19. 42
      libs/remix-git/src/index.ts
  20. 1
      libs/remix-ui/editor/src/lib/remix-plugin-types.ts
  21. 2
      libs/remix-ui/git/src/components/buttons/sourceControlBase.tsx
  22. 2
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  23. 2
      libs/remix-ui/git/src/components/github/repositoryselect.tsx
  24. 2
      libs/remix-ui/git/src/components/github/selectandclonerepositories.tsx
  25. 2
      libs/remix-ui/git/src/components/navigation/branchedetails.tsx
  26. 2
      libs/remix-ui/git/src/components/navigation/commits.tsx
  27. 2
      libs/remix-ui/git/src/components/navigation/remotesdetails.tsx
  28. 1
      libs/remix-ui/git/src/components/panels/branches.tsx
  29. 2
      libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx
  30. 2
      libs/remix-ui/git/src/components/panels/branches/branchdifferences.tsx
  31. 2
      libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx
  32. 2
      libs/remix-ui/git/src/components/panels/branches/remotebranchedetails.tsx
  33. 2
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  34. 2
      libs/remix-ui/git/src/components/panels/commits/commitdetailsitem.tsx
  35. 2
      libs/remix-ui/git/src/components/panels/remoteselect.tsx
  36. 2
      libs/remix-ui/git/src/components/panels/remotesimport.tsx
  37. 3
      libs/remix-ui/git/src/components/panels/sourcecontrol/sourcecontrolitem.tsx
  38. 2
      libs/remix-ui/git/src/components/panels/sourcecontrol/sourcontrolitembuttons.tsx
  39. 2
      libs/remix-ui/git/src/index.ts
  40. 14
      libs/remix-ui/git/src/lib/gitactions.ts
  41. 15
      libs/remix-ui/git/src/lib/listeners.ts
  42. 4
      libs/remix-ui/git/src/lib/pluginActions.ts
  43. 4
      libs/remix-ui/git/src/state/actions.ts
  44. 9
      libs/remix-ui/git/src/state/context.tsx
  45. 4
      libs/remix-ui/git/src/state/gitpayload.ts
  46. 6
      libs/remix-ui/git/src/state/gitreducer.tsx
  47. 215
      libs/remix-ui/git/src/types/index.ts
  48. 15
      libs/remix-ui/workspace/src/lib/actions/workspace.ts

@ -19,10 +19,12 @@ import { Octokit, App } from "octokit"
import { OctokitResponse } from '@octokit/types'
import { Endpoints } from "@octokit/types"
import { IndexedDBStorage } from './filesystems/indexedDB'
import { GitHubUser, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput, userEmails, checkoutInput } from '@remix-ui/git'
import { GitHubUser, branch, commitChange, remote, userEmails } from '@remix-ui/git'
import { checkoutInputType, statusInput, logInputType, author, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInputType, rmInputType, resolveRefInput, readBlobInput, repositoriesInput, commitInputType, branchDifference, compareBranchesInput, initInputType} from '@remix-api'
import { LibraryProfile, StatusEvents } from '@remixproject/plugin-utils'
import { ITerminal } from '@remixproject/plugin-api/src/lib/terminal'
import { partial } from 'lodash'
import { CustomRemixApi } from '@remix-api'
declare global {
interface Window { remixFileSystemCallback: IndexedDBStorage; remixFileSystem: any; }
@ -34,11 +36,11 @@ const profile: LibraryProfile = {
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', 'reset', 'rm', 'lsfiles', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pull', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'version', 'updateSubmodules'
methods: ['init', 'localStorageUsed', 'addremote', 'delremote', 'remotes', 'fetch', 'clone', 'export', 'import', 'status', 'log', 'commit', 'add', 'remove', 'rm', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pull', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'version', 'updateSubmodules'
, 'getGitHubUser', 'remotebranches', 'remotecommits', 'repositories', 'getCommitChanges', 'compareBranches'],
kind: 'file-system'
}
class DGitProvider extends Plugin {
class DGitProvider extends Plugin<any, CustomRemixApi> {
ipfsconfig: { host: string; port: number; protocol: string; ipfsurl: string }
globalIPFSConfig: { host: string; port: number; protocol: string; ipfsurl: string }
remixIPFS: { host: string; port: number; protocol: string; ipfsurl: string }
@ -141,7 +143,7 @@ class DGitProvider extends Plugin {
}
async getCommandUser(input) {
const author = {
const author: author = {
name: '',
email: ''
}
@ -167,7 +169,7 @@ class DGitProvider extends Plugin {
return author
}
async init(input?: initInput): Promise<void> {
async init(input?: initInputType): Promise<void> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'init', {
defaultBranch: (input && input.defaultBranch) || 'main'
@ -192,7 +194,7 @@ class DGitProvider extends Plugin {
return version
}
async status(cmd): Promise<Array<StatusRow>> {
async status(cmd: statusInput): Promise<Array<StatusRow>> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const status = await this.call('isogit', 'status', cmd)
@ -208,7 +210,7 @@ class DGitProvider extends Plugin {
return status
}
async add(cmd: addInput): Promise<void> {
async add(cmd: addInputType): Promise<void> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'add', cmd)
@ -222,7 +224,7 @@ class DGitProvider extends Plugin {
this.emit('add')
}
async rm(cmd: rmInput) {
async rm(cmd: rmInputType) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'rm', cmd)
@ -236,21 +238,7 @@ class DGitProvider extends Plugin {
}
}
async reset(cmd) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'reset', cmd)
} else {
await git.resetIndex({
...await this.addIsomorphicGitConfigFS(),
...cmd
})
this.emit('rm')
}
}
async checkout(cmd: checkoutInput): Promise<void> {
async checkout(cmd: checkoutInputType): Promise<void> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'checkout', cmd)
@ -291,12 +279,11 @@ class DGitProvider extends Plugin {
this.emit('checkout')
}
async log(cmd: { ref: string }): Promise<ReadCommitResult[]> {
async log(cmd: logInputType): Promise<ReadCommitResult[]> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const status = await this.call('isogit', 'log', {
...cmd,
depth: 10
})
return status
@ -310,6 +297,9 @@ class DGitProvider extends Plugin {
}
async compareBranches({ branch, remote }: compareBranchesInput): Promise<branchDifference> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'compareBranches', { branch, remote })
}
// Get current branch commits
const headCommits = await git.log({
...await this.addIsomorphicGitConfigFS(),
@ -339,6 +329,11 @@ class DGitProvider extends Plugin {
}
async getCommitChanges(commitHash1: string, commitHash2: string): Promise<commitChange[]> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const result = this.call('isogit', 'getCommitChanges', commitHash1, commitHash2 )
return result
}
const result: commitChange[] = await git.walk({
...await this.addIsomorphicGitConfigFS(),
trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })],
@ -388,14 +383,14 @@ class DGitProvider extends Plugin {
return result
}
async remotes(config): Promise<remote[]> {
async remotes(): Promise<remote[]> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'remotes', config)
return await this.call('isogit', 'remotes')
}
let remotes: remote[] = []
try {
remotes = (await git.listRemotes({ ...config ? config : await this.addIsomorphicGitConfigFS() })).map((remote) => { return { name: remote.remote, url: remote.url } }
remotes = (await git.listRemotes({ ...await this.addIsomorphicGitConfigFS() })).map((remote) => { return { name: remote.remote, url: remote.url } }
)
} catch (e) {
// do nothing
@ -423,15 +418,15 @@ class DGitProvider extends Plugin {
return status
}
async currentbranch(config: currentBranchInput): Promise<branch> {
async currentbranch(input: currentBranchInput): Promise<branch> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'currentbranch')
return await this.call('isogit', 'currentbranch', input)
}
try {
const defaultConfig = await this.addIsomorphicGitConfigFS()
const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig
const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig
const name = await git.currentBranch(cmd)
let remote: remote = undefined
try {
@ -463,13 +458,15 @@ class DGitProvider extends Plugin {
async branches(config): Promise<branch[]> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'branches')
const branches = await this.call('isogit', 'branches')
console.log(branches)
return branches
}
try {
const defaultConfig = await this.addIsomorphicGitConfigFS()
const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig
const remotes = await this.remotes(config)
const remotes = await this.remotes()
let branches: branch[] = []
branches = (await git.listBranches(cmd)).map((branch) => { return { remote: undefined, name: branch } })
for (const remote of remotes) {
@ -484,7 +481,7 @@ class DGitProvider extends Plugin {
}
}
async commit(cmd: commitInput): Promise<string> {
async commit(cmd: commitInputType): Promise<string> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
try {
@ -511,19 +508,6 @@ class DGitProvider extends Plugin {
}
}
async lsfiles(cmd) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'lsfiles', cmd)
}
const filesInStaging = await git.listFiles({
...await this.addIsomorphicGitConfigFS(),
...cmd
})
return filesInStaging
}
async resolveref(cmd: resolveRefInput): Promise<string> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
@ -569,7 +553,7 @@ class DGitProvider extends Plugin {
async addremote(input: remote): Promise<void> {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'addremote', { url: input.url, remote: input.name })
await this.call('isogit', 'addremote', input)
return
}
await git.addRemote({ ...await this.addIsomorphicGitConfigFS(), url: input.url, remote: input.name })
@ -577,7 +561,7 @@ class DGitProvider extends Plugin {
async delremote(input: remote) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
await this.call('isogit', 'delremote', { remote: input.name })
await this.call('isogit', 'delremote', input)
return
}
await git.deleteRemote({ ...await this.addIsomorphicGitConfigFS(), remote: input.name })
@ -608,6 +592,7 @@ class DGitProvider extends Plugin {
} catch (e) {
this.call('notification', 'alert', {
id: 'dgitAlert',
title: 'Error Cloning',
message: 'Unexpected error while cloning the repository: \n' + e.toString(),
})
}
@ -791,7 +776,10 @@ class DGitProvider extends Plugin {
input,
}
if ((Registry.getInstance().get('platform').api.isDesktop())) {
return await this.call('isogit', 'push', cmd)
return await this.call('isogit', 'push', {
...input,
author: await this.getCommandUser(input),
})
} else {
const cmd2 = {
@ -820,7 +808,10 @@ class DGitProvider extends Plugin {
}
let result
if ((Registry.getInstance().get('platform').api.isDesktop())) {
result = await this.call('isogit', 'pull', cmd)
result = await this.call('isogit', 'pull', {
...input,
author: await this.getCommandUser(input),
})
}
else {
const cmd2 = {
@ -852,7 +843,10 @@ class DGitProvider extends Plugin {
let result
if ((Registry.getInstance().get('platform').api.isDesktop())) {
result = await this.call('isogit', 'fetch', cmd)
result = await this.call('isogit', 'fetch', {
...input,
author: await this.getCommandUser(input),
})
} else {
const cmd2 = {
...cmd,
@ -1072,6 +1066,7 @@ class DGitProvider extends Plugin {
}
async remotecommits(input: remoteCommitsInputType): Promise<pagedCommits[]> {
console.log('remotecommits', input)
const octokit = new Octokit({
auth: input.token
})

@ -1,7 +1,7 @@
{
"name": "remixdesktop",
"version": "1.0.7-insiders",
"main": "build/main.js",
"main": "build/apps/remixdesktop/src/main.js",
"license": "MIT",
"type": "commonjs",
"description": "Remix IDE Desktop",

@ -145,6 +145,9 @@ HelpMenu(commandKeys, execCommand),
if (!isE2E || isE2ELocal)
Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
ipcMain.handle('logger', async (...args) => {
console.log('log:', ...args)
})
ipcMain.handle('config:isPackaged', async () => {
return isPackaged

@ -78,14 +78,11 @@ const clientProfile: Profile = {
class AppUpdaterPluginClient extends ElectronBasePluginClient {
constructor(webContentsId: number, profile: Profile) {
console.log('AppUpdaterPluginClient')
super(webContentsId, profile)
}
async onActivation(): Promise<void> {
console.log('onActivation', 'appUpdaterPluginClient')
this.onload(async () => {
console.log('onload', 'appUpdaterPluginClient')
this.emit('loaded')
if(isE2E) return
await this.checkForUpdates()

@ -33,7 +33,6 @@ const getBaseName = (pathName: string): string => {
}
function onlyUnique(value: recentFolder, index: number, self: recentFolder[]) {
console.log(index, value)
return self.findIndex((rc, index) => rc.path === value.path) === index
}

@ -1,12 +1,11 @@
import { PluginClient } from "@remixproject/plugin";
import { Profile } from "@remixproject/plugin-utils";
import { ElectronBasePlugin, ElectronBasePluginClient } from "@remixproject/plugin-electron"
import fs from 'fs/promises'
import git from 'isomorphic-git'
import { dialog } from "electron";
import http from 'isomorphic-git/http/web'
import { gitProxy } from "../tools/git";
import { remote } from "../types";
import { isoGit } from "@remix-git"
import { branch, branchDifference, branchInputType, cloneInputType, commitChange, commitInputType, compareBranchesInput, currentBranchInput, fetchInputType, initInputType, logInputType, pullInputType, pushInputType, remote, resolveRefInput, statusInput } from "@remix-api";
const profile: Profile = {
name: 'isogit',
@ -48,7 +47,7 @@ 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', 'reset', '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', 'rm', 'readblob', 'resolveref', 'branches', 'branch', 'checkout', 'currentbranch', 'push', 'pin', 'pull', 'pinList', 'unPin', 'setIpfsConfig', 'zip', 'setItem', 'getItem', 'openFolder', 'getCommitChanges', 'compareBranches', 'startClone']
}
class IsoGitPluginClient extends ElectronBasePluginClient {
@ -77,8 +76,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
}
async status(cmd: any) {
async status(cmd: statusInput) {
console.log('status', cmd)
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
@ -101,8 +100,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return status
}
async log(cmd: any) {
async log(cmd: logInputType) {
console.log('LOG', cmd)
/* we will use isomorphic git for now
if(this.gitIsInstalled){
const log = await gitProxy.log(this.workingDir, cmd.ref)
@ -150,28 +149,13 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return rm
}
async reset(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
const reset = await git.resetIndex({
...await this.getGitConfig(),
...cmd
})
return reset
}
async commit(cmd: any) {
async commit(cmd: commitInputType) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
const status = await gitProxy.commit(this.workingDir, cmd.message)
const status = await gitProxy.commit(this.workingDir, cmd)
return status
}
@ -183,7 +167,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return commit
}
async init(input: any) {
async init(input: initInputType) {
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
@ -194,11 +178,11 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
await git.init({
...await this.getGitConfig(),
defaultBranch: (input && input.branch) || 'main'
defaultBranch: (input && input.defaultBranch) || 'main'
})
}
async branch(cmd: any) {
async branch(cmd: branchInputType) {
if (!this.workingDir || this.workingDir === '') {
return null
}
@ -210,18 +194,8 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return branch
}
async lsfiles(cmd: any) {
if (!this.workingDir || this.workingDir === '') {
return []
}
const lsfiles = await git.listFiles({
...await this.getGitConfig(),
...cmd
})
return lsfiles
}
async resolveref(cmd: any) {
async resolveref(cmd: resolveRefInput) {
console.log('RESOLVE REF', cmd)
if (!this.workingDir || this.workingDir === '') {
return null
}
@ -230,7 +204,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
...await this.getGitConfig(),
...cmd
})
console.log('RESOLVE REF', resolveref)
return resolveref
}
@ -263,38 +237,38 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
return checkout
}
async push(cmd: any) {
async push(cmd: pushInputType) {
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)
await gitProxy.push(this.workingDir, cmd)
} else {
/*
const push = await git.push({
...await this.getGitConfig(),
...cmd,
...parseInput(cmd.input)
})
return push
return push*/
}
}
async pull(cmd: any) {
async pull(cmd: pullInputType) {
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)
await gitProxy.pull(this.workingDir, cmd)
} else {
/*
const pull = await git.pull({
...await this.getGitConfig(),
...cmd,
@ -302,41 +276,42 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
})
return pull
*/
}
}
async fetch(cmd: any) {
async fetch(cmd: fetchInputType) {
console.log('FETCH', cmd)
if (!this.workingDir || this.workingDir === '') {
throw new Error('No working directory')
}
if (this.gitIsInstalled) {
await gitProxy.fetch(this.workingDir, cmd.remote, cmd.remoteRef)
await gitProxy.fetch(this.workingDir, cmd)
} else {
/*
const fetch = await git.fetch({
...await this.getGitConfig(),
...cmd,
...parseInput(cmd.input)
})
*/
return fetch
}
}
async clone(cmd: any) {
async clone(cmd: cloneInputType) {
if (this.gitIsInstalled) {
try {
await gitProxy.clone(cmd.url, cmd.dir)
await gitProxy.clone(cmd)
} catch (e) {
throw e
}
} else {
try {
/*
this.call('terminal' as any, 'log', 'Cloning using builtin git... please wait.')
const clone = await git.clone({
...await this.getGitConfig(),
@ -346,6 +321,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
})
return clone
*/
} catch (e) {
console.log('CLONE ERROR', e)
throw e
@ -353,21 +329,21 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
}
async addremote(cmd: any) {
async addremote(input: remote) {
const addremote = await git.addRemote({
...await this.getGitConfig(),
...cmd
url: input.url, remote: input.name
})
return addremote
}
async delremote(cmd: any) {
async delremote(input: remote) {
const delremote = await git.deleteRemote({
...await this.getGitConfig(),
...cmd
remote: input.name
})
return delremote
@ -375,53 +351,83 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
remotes = async () => {
async remotes () {
console.log('REMOTES')
if (!this.workingDir || this.workingDir === '') {
return []
}
let remotes: remote[] = []
remotes = (await git.listRemotes({ ...await this.getGitConfig() })).map((remote) => { return { name: remote.remote, url: remote.url } }
)
try {
remotes = (await git.listRemotes({ ...await this.getGitConfig() })).map((remote) => { return { name: remote.remote, url: remote.url } }
)
} catch (e) {
// do nothing
}
console.log('REMOTES', remotes)
return remotes
}
async currentbranch() {
async currentbranch(input: currentBranchInput) {
console.log('CURRENT BRANCH', input)
if (!this.workingDir || this.workingDir === '') {
return ''
}
try {
const defaultConfig = await this.getGitConfig()
const name = await git.currentBranch(defaultConfig)
console.log(isoGit)
const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig
const name = await git.currentBranch(cmd)
let remote: remote = undefined
try {
const remoteName = await git.getConfig({
...defaultConfig,
path: `branch.${name}.remote`
})
if (remoteName) {
const remoteUrl = await git.getConfig({
...defaultConfig,
path: `remote.${remoteName}.url`
})
remote = { name: remoteName, url: remoteUrl }
}
return name
} catch (e) {
// do nothing
}
console.log('NAME', name)
console.log('REMOTE', remote)
return {
remote: remote,
name: name || ''
}
} catch (e) {
return ''
return undefined
}
}
async branches() {
async branches(config: any) {
console.log('BRANCHES')
if (!this.workingDir || this.workingDir === '') {
return []
}
try {
let cmd: any = { ...await this.getGitConfig() }
const defaultConfig = await this.getGitConfig()
const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig
const remotes = await this.remotes()
let branches = []
let branches: branch[] = []
branches = (await git.listBranches(cmd)).map((branch) => { return { remote: undefined, name: branch } })
for (const remote of remotes) {
cmd = {
...cmd,
remote: remote.name
}
const remotebranches = (await git.listBranches(cmd)).map((branch) => { return { remote: remote.name, name: branch } })
cmd.remote = remote.name
const remotebranches = (await git.listBranches(cmd)).map((branch) => { return { remote: remote, name: branch } })
branches = [...branches, ...remotebranches]
}
return branches
} catch (e) {
console.log(e)
return []
}
}
@ -431,6 +437,86 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
this.call('filePanel' as any, 'clone')
}
async getCommitChanges(commitHash1: string, commitHash2: string): Promise<commitChange[]> {
const result: commitChange[] = await git.walk({
...await this.getGitConfig(),
trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })],
map: async function (filepath, [A, B]) {
if (filepath === '.') {
return
}
try {
if ((A && await A.type()) === 'tree' || B && (await B.type()) === 'tree') {
return
}
} catch (e) {
// ignore
}
// generate ids
const Aoid = A && await A.oid() || undefined
const Boid = B && await B.oid() || undefined
const commitChange: Partial<commitChange> = {
hashModified: commitHash1,
hashOriginal: commitHash2,
path: filepath,
}
// determine modification type
if (Aoid !== Boid) {
commitChange.type = "modified"
}
if (Aoid === undefined) {
commitChange.type = "deleted"
}
if (Boid === undefined || !commitHash2) {
commitChange.type = "added"
}
if (Aoid === undefined && Boid === undefined) {
commitChange.type = "unknown"
}
if (commitChange.type)
return commitChange
else
return undefined
},
})
return result
}
async compareBranches({ branch, remote }: compareBranchesInput): Promise<branchDifference> {
// Get current branch commits
const headCommits = await git.log({
...await this.getGitConfig(),
ref: branch.name,
});
// Get remote branch commits
const remoteCommits = await git.log({
...await this.getGitConfig(),
ref: `${remote.name}/${branch.name}`,
});
// Convert arrays of commit objects to sets of commit SHAs
const headCommitSHAs = new Set(headCommits.map(commit => commit.oid));
const remoteCommitSHAs = new Set(remoteCommits.map(commit => commit.oid));
// Filter out commits that are only in the remote branch
const uniqueRemoteCommits = remoteCommits.filter(commit => !headCommitSHAs.has(commit.oid));
// filter out commits that are only in the local branch
const uniqueHeadCommits = headCommits.filter(commit => !remoteCommitSHAs.has(commit.oid));
return {
uniqueHeadCommits,
uniqueRemoteCommits,
};
}
}

@ -28,10 +28,17 @@ contextBridge.exposeInMainWorld('electronAPI', {
plugins: exposedPLugins.map(name => {
return {
name,
on: (cb:any) => ipcRenderer.on(`${name}:send`, cb),
on: (cb:any) => {
if(name === 'isogit') console.log('isogit', cb)
ipcRenderer.on(`${name}:send`, cb)
},
send: (message: Partial<Message>) => {
//if(name === 'isogit') console.log(name, message)
//if(name === 'isogit') ipcRenderer.invoke(`logger`, name, message)
ipcRenderer.send(`${name}:on:${webContentsId}`, message)
}
}
})
})

@ -1,6 +1,7 @@
import { exec } from 'child_process';
import { CommitObject, ReadCommitResult } from 'isomorphic-git';
import { promisify } from 'util';
import { cloneInputType, commitInputType, fetchInputType, pullInputType, pushInputType } from "@remix-api";
const execAsync = promisify(exec);
const statusTransFormMatrix = (status: string) => {
@ -37,27 +38,56 @@ export const gitProxy = {
}
},
async defaultRemoteName(path: string) {
try {
const { stdout } = await execAsync('git remote', { cwd: path });
const remotes = stdout.trim().split('\n');
return remotes[0];
} catch (error) {
throw new Error(`Failed to get the default remote name: ${error.message}`);
}
},
clone: async (url: string, path: string) => {
const { stdout, stderr } = await execAsync(`git clone ${url} "${path}"`);
clone: async (input: cloneInputType) => {
const { stdout, stderr } = await execAsync(`git clone ${input.url} "${input.dir}"`);
},
async push(path: string, remote: string, src: string, branch: string, force: boolean = false) {
const { stdout, stderr } = await execAsync(`git push ${force ? ' -f' : ''} ${remote} ${src}:${branch}`, { cwd: path });
async push(path: string, input: pushInputType) {
if(!input.remote || !input.remote.name) {
input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' }
}
const { stdout, stderr } = await execAsync(`git push ${input.force ? ' -f' : ''} ${input.remote.name} ${input.ref.name}:${input.remoteRef.name}`, { cwd: path });
},
async pull(path: string, remote: string, src: string, branch: string) {
const { stdout, stderr } = await execAsync(`git pull ${remote} ${src}:${branch}`, { cwd: path });
async pull(path: string, input: pullInputType) {
if(!input.remote || !input.remote.name) {
input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' }
}
const { stdout, stderr } = await execAsync(`git pull ${input.remote.name} ${input.ref.name}:${input.remoteRef.name}`, { cwd: path });
},
async fetch(path: string, remote: string, branch: string) {
const { stdout, stderr } = await execAsync(`git fetch ${remote} ${branch}`, { cwd: path });
async fetch(path: string, input: fetchInputType) {
if(!input.remote || !input.remote.name) {
input.remote = { name: await gitProxy.defaultRemoteName(path), url: '' }
}
console.log('fetch', input, path, `git fetch ${input.remote.name} ${(input.ref && input.ref.name) ? input.ref.name : ''}`);
try {
const { stdout, stderr } = await execAsync(`git fetch ${input.remote.name} ${(input.ref && input.ref.name) ? input.ref.name : ''}`, { cwd: path });
if (stdout) {
console.log('stdout:', stdout);
}
if (stderr) {
console.error('stderr:', stderr);
}
} catch (error) {
console.error('Error during fetch:', error);
}
},
async commit(path: string, message: string) {
async commit(path: string, input: commitInputType) {
await execAsync(`git commit -m '${message}'`, { cwd: path });
await execAsync(`git commit -m '${input.message}'`, { cwd: path });
const { stdout, stderr } = await execAsync(`git rev-parse HEAD`, { cwd: path });
return stdout;
@ -103,7 +133,7 @@ export const gitProxy = {
return 0
})
console.log('files', files)
return files
},

@ -1,9 +0,0 @@
export type branch = {
name: string
remote: remote
}
export type remote = {
name: string
url: string
}

@ -9,13 +9,29 @@
"noImplicitAny": false,
"sourceMap": true,
"baseUrl": ".",
"outDir": "build",
"outDir": "./build",
"moduleResolution": "node",
"resolveJsonModule": true,
"paths": {
"*": ["node_modules/*"]
"*": [
"node_modules/*"
],
"@remix-api": [
"../../libs/remix-api/src/lib/types/git.ts"
],
"@remix-git": [
"../../libs/remix-git/src/index.ts",
],
},
"typeRoots": ["src/**/*.d.ts", "node_modules/@types", "test/**/*.d.ts", "../remix-ide-e2e/src/**/*.d.ts"]
"typeRoots": [
"src/**/*.d.ts",
"node_modules/@types",
"test/**/*.d.ts",
"../remix-ide-e2e/src/**/*.d.ts"
]
},
"include": ["src/**/*"]
"include": [
"src/**/*",
"../../libs/remix-git/src/index.ts"
]
}

@ -1 +1,2 @@
export * from './lib/remix-api'
export * from './lib/remix-api'
export * from './lib/types/git'

@ -1,10 +1,13 @@
import { commitChange } from "@remix-ui/git";
import { commitChange } from "@remix-api";
import { IFileSystem } from "@remixproject/plugin-api"
// Extended interface with 'diff' method
export interface IExtendedFileSystem extends IFileSystem {
methods: IFileSystem['methods'] & {
/** Compare the differences between two files */
diff(change: commitChange): Promise<void>
refresh(): Promise<void>
hasGitSubmodules(): Promise<boolean>
isGitRepo(): Promise<boolean>
};
}

@ -0,0 +1,11 @@
import { StatusEvents } from "@remixproject/plugin-utils";
export interface IFs {
events: {
workingDirChanged(path: string): Promise<void>,
} & StatusEvents,
methods: {
selectFolder(path?: string, title?: string, button?: string): Promise<string>
openWindow(path?: string): Promise<void>,
}
}

@ -0,0 +1,43 @@
import { StatusEvents } from "@remixproject/plugin-utils"
import { ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git"
import { commitChange, repositoriesInput, repository, cloneInputType, branchesInputType, branch, remote, logInputType, remoteCommitsInputType, pagedCommits, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, checkoutInputType, addInputType, rmInputType, resolveRefInput, readBlobInput, commitInputType, statusInput, compareBranchesInput, branchDifference, initInputType, updateSubmodulesInput } from "../types/git"
export interface IGitApi {
events: {
"checkout": () => void
"clone": () => void
"add": () => void
"rm": () => void
"commit": () => void
"branch": () => void
"init": () => void
} & StatusEvents,
methods: {
getCommitChanges(oid1: string, oid2: string): Promise<commitChange[]>
repositories(input: repositoriesInput): Promise<repository[]>
clone(input: cloneInputType): Promise<any>
branches(input?: branchesInputType): Promise<branch[]>,
remotes(): Promise<remote[]>,
log(input: logInputType): Promise<ReadCommitResult[]>,
remotecommits(input: remoteCommitsInputType): Promise<pagedCommits[]>
fetch(input: fetchInputType): Promise<any>
pull(input: pullInputType): Promise<any>
push(input: pushInputType): Promise<any>
currentbranch(input?: currentBranchInput): Promise<branch>
branch(input: branchInputType): Promise<void>
checkout(input: checkoutInputType): Promise<void>
add(input: addInputType): Promise<void>
rm(input: rmInputType): Promise<void>
resolveref(input: resolveRefInput): Promise<string>
readblob(input: readBlobInput): Promise<ReadBlobResult>
commit(input: commitInputType): Promise<string>
addremote(input: remote): Promise<void>
delremote(input: remote): Promise<void>
status(input?: statusInput): Promise<Array<StatusRow>>
compareBranches(input: compareBranchesInput): Promise<branchDifference>
init(input?: initInputType): Promise<void>
updateSubmodules: (input: updateSubmodulesInput) => Promise<void>
version: () => Promise<string>
}
}

@ -0,0 +1,10 @@
import { ITerminal } from "@remixproject/plugin-api/src/lib/terminal"
import { StatusEvents } from "@remixproject/plugin-utils"
export interface IExtendedTerminalApi extends ITerminal {
events: {
} & StatusEvents
methods: ITerminal['methods'] & {
logHtml(html: string): void
}
}

@ -1,13 +1,14 @@
import { IGitApi } from "@remix-ui/git"
import { IRemixApi } from "@remixproject/plugin-api"
import { StatusEvents } from "@remixproject/plugin-utils"
import { IConfigApi } from "./plugins/config-api"
import { IFileDecoratorApi } from "./plugins/filedecorator-api"
import { IExtendedFileSystem } from "./plugins/fileSystem-api"
import { IFs } from "./plugins/fs-api"
import { IGitApi } from "./plugins/git-api"
import { INotificationApi } from "./plugins/notification-api"
import { ISettings } from "./plugins/settings-api"
import { IExtendedTerminalApi } from "./plugins/terminal-api"
import { IFilePanelApi } from "./plugins/filePanel-api"
import { Plugin } from "@remixproject/engine"
export interface ICustomRemixApi extends IRemixApi {
dgitApi: IGitApi
@ -16,6 +17,9 @@ export interface ICustomRemixApi extends IRemixApi {
settings: ISettings
fileDecorator: IFileDecoratorApi
fileManager: IExtendedFileSystem
isogit: IGitApi,
terminal: IExtendedTerminalApi
fs: IFs
filePanel: IFilePanelApi
}

@ -0,0 +1,189 @@
import { ReadCommitResult } from "isomorphic-git"
export type branchDifference = {
uniqueHeadCommits: ReadCommitResult[],
uniqueRemoteCommits: ReadCommitResult[],
}
export type commitChange = {
type: commitChangeType
path: string,
hashModified: string,
hashOriginal: string,
original?: string,
modified?: string,
readonly?: boolean
}
export type commitChangeTypes = {
"deleted": "D"
"modified": "M"
"added": "A",
"unknown": "?"
}
export type pagedCommits = {
page: number,
perPage: number,
total: number,
hasNextPage: boolean,
commits: ReadCommitResult[]
}
export enum syncStatus {
"sync" = "sync",
"publishBranch" = "publishBranch",
"none" = "none",
}
export type repository = {
name: string
html_url: string
owner: {
login: string
},
full_name: string
default_branch: string
id: number
url: string
}
export type branch = {
name: string
remote: remote
}
export type remote = {
name: string
url: string
}
export type remoteBranch = {
name: string
}
export type commitChangeType = keyof commitChangeTypes
export type initInputType = {
defaultBranch: string
}
export type author = {
name: string,
email: string
}
export type updateSubmodulesInput = {
dir?: string
token?: string
}
export type remoteCommitsInputType = {
owner: string, repo: string, token: string, branch: string, length: number, page: number
}
export type compareBranchesInput = {
branch: branch, remote: remote
}
export type fetchInputType = {
remote: remote,
ref?: branch,
remoteRef?: branch,
depth?: number,
singleBranch?: boolean,
relative?: boolean,
quiet?: boolean
author?: author
}
export type logInputType = {
ref: string,
depth?: number,
}
export type pullInputType = {
remote: remote,
ref: branch,
remoteRef?: branch
author?: author
}
export type pushInputType = {
remote: remote,
ref: branch,
remoteRef?: branch,
force?: boolean,
author?: author
}
export type branchInputType = {
ref: string,
checkout?: boolean
refresh?: boolean
force?: boolean
}
export type currentBranchInput = {
fs: any,
dir: string
}
export type checkoutInputType = {
ref: string,
force?: boolean,
remote?: string
refresh?: boolean
fetch?: boolean
}
export type addInputType = {
filepath: string | string[]
}
export type rmInputType = {
filepath: string
}
export type resolveRefInput = {
ref: string
}
export type readBlobInput = {
oid: string,
filepath: string
}
export type commitInputType = {
author: {
name: string,
email: string,
},
message: string,
}
export type branchesInputType = {
fs?: any
dir?: string
}
export interface cloneInputType {
url: string,
branch?: string,
depth?: number,
singleBranch?: boolean
workspaceName?: string
workspaceExists?: boolean
token?: string
dir?: string // where the clone should happen on desktop
}
export interface repositoriesInput { token: string, page?: number, per_page?: number }
export interface statusInput { ref: string, filepaths?: string[] }
export type isoGitConfig = {
fs: any,
dir: string,
}

@ -0,0 +1 @@
export * from './src/index'

@ -0,0 +1,42 @@
import { currentBranchInput, isoGitConfig, remote } from "@remix-api"
import git from 'isomorphic-git'
const currentbranch = async (input: currentBranchInput, defaultConfig: isoGitConfig ) => {
console.log('CURRENT BRANCH', input)
try {
const cmd = input ? defaultConfig ? { ...defaultConfig, ...input } : input : defaultConfig
const name = await git.currentBranch(cmd)
let remote: remote = undefined
try {
const remoteName = await git.getConfig({
...defaultConfig,
path: `branch.${name}.remote`
})
if (remoteName) {
const remoteUrl = await git.getConfig({
...defaultConfig,
path: `remote.${remoteName}.url`
})
remote = { name: remoteName, url: remoteUrl }
}
} catch (e) {
// do nothing
}
console.log('NAME', name)
console.log('REMOTE', remote)
return {
remote: remote,
name: name || ''
}
} catch (e) {
return undefined
}
}
export const isoGit = {
currentbranch
}

@ -380,7 +380,6 @@ declare interface IDgitSystem {
status(cmd: any): any[];
rm(cmd: any): string;
log(cmd: any): any[];
lsfiles(cmd: any): any[];
readblob(cmd: any): { oid: string, blob: Uint8Array }
resolveref(cmd: any): string
branch(cmd: any): void

@ -5,7 +5,7 @@ import { ReadCommitResult } from "isomorphic-git"
import React, { createContext, useEffect, useState } from "react"
import { FormattedMessage } from "react-intl"
import { gitActionsContext } from "../../state/context"
import { branch, remote } from "../../types"
import { branch, remote } from "@remix-api"
import { gitPluginContext } from "../gitui"
import GitUIButton from "./gituibutton"

@ -4,7 +4,7 @@ import { CustomTooltip } from "@remix-ui/helper"
import React, { useEffect, useState } from "react"
import { FormattedMessage } from "react-intl"
import { gitActionsContext } from "../../state/context"
import { branch, remote } from "../../types"
import { branch, remote } from "@remix-api"
import { gitPluginContext } from "../gitui"
import GitUIButton from "./gituibutton"
import { syncStateContext } from "./sourceControlBase"

@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Button } from 'react-bootstrap';
import Select from 'react-select';
import { gitActionsContext } from '../../state/context';
import { repository } from '../../types';
import { repository } from '@remix-api';
import { selectStyles, selectTheme } from '../../types/styles';
import { gitPluginContext } from '../gitui';
import { TokenWarning } from '../panels/tokenWarning';

@ -1,6 +1,6 @@
import React, { useEffect, useState } from "react";
import { gitActionsContext } from "../../state/context";
import { repository } from "../../types";
import { repository } from "@remix-api";
import { gitPluginContext } from "../gitui";
import RepositorySelect from "./repositoryselect";
import { BranchSelect } from "./branchselect";

@ -2,7 +2,7 @@ import { faCaretUp, faCaretDown, faCaretRight, faArrowUp, faArrowDown, faArrowRo
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useContext, useEffect } from "react";
import { gitActionsContext } from "../../state/context";
import { branch } from "../../types";
import { branch } from "@remix-api";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";

@ -4,7 +4,7 @@ import { CustomTooltip } from "@remix-ui/helper";
import React, { useEffect } from "react";
import { FormattedMessage } from "react-intl";
import { pluginActionsContext } from "../../state/context";
import { branch, remote } from "../../types";
import { branch, remote } from "@remix-api";
import { SourceControlBase } from "../buttons/sourceControlBase";
import { SourceControlButtons } from "../buttons/sourcecontrolbuttons";
import { gitPluginContext } from "../gitui";

@ -3,7 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { CustomTooltip } from "@remix-ui/helper";
import React, { useContext, useEffect } from "react";
import { gitActionsContext } from "../../state/context";
import { branch, remote } from "../../types";
import { remote } from "@remix-api";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";

@ -1,7 +1,6 @@
import React, { useEffect, useState } from "react";
import { Alert } from "react-bootstrap";
import { gitActionsContext } from "../../state/context";
import { remote } from "../../types";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";
import { LocalBranchDetails } from "./branches/localbranchdetails";

@ -3,7 +3,7 @@ import { Accordion } from "react-bootstrap";
import React, { useEffect, useState } from "react";
import { CommitDetails } from "../commits/commitdetails";
import { CommitsNavigation } from "../../navigation/commits";
import { branch, remote } from "../../../types";
import { branch, remote } from "@remix-api";
import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui";

@ -1,4 +1,4 @@
import { branch, remote } from "../../../types";
import { branch, remote } from "@remix-api";
import React, { useEffect, useState } from "react";
import { gitPluginContext } from "../../gitui";
import { CommitDetails } from "../commits/commitdetails";

@ -4,7 +4,7 @@ import { Accordion } from "react-bootstrap";
import { CommitDetailsNavigation } from "../../navigation/commitdetails";
import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui";
import { branch } from "../../../types";
import { branch } from "@remix-api";
import { BrancheDetailsNavigation } from "../../navigation/branchedetails";
import { CommitDetailsItems } from "../commits/commitdetailsitem";
import { CommitDetails } from "../commits/commitdetails";

@ -4,7 +4,7 @@ import { Accordion } from "react-bootstrap";
import { CommitDetailsNavigation } from "../../navigation/commitdetails";
import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui";
import { branch } from "../../../types";
import { branch } from "@remix-api";
import { BrancheDetailsNavigation } from "../../navigation/branchedetails";
import { CommitDetailsItems } from "../commits/commitdetailsitem";
import { CommitDetails } from "../commits/commitdetails";

@ -4,7 +4,7 @@ import { gitPluginContext } from "../../gitui";
import { selectStyles, selectTheme } from "../../../types/styles";
import Select, { Options, OptionsOrGroups } from 'react-select'
import GitUIButton from "../../buttons/gituibutton";
import { remote } from "../../../types";
import { remote } from "@remix-api";
import { relative } from "path";
export const PushPull = () => {

@ -1,4 +1,4 @@
import { branch, commitChange } from "../../../types";
import { branch, commitChange } from "@remix-api";
import React from "react";
import path from "path";
import { gitActionsContext, pluginActionsContext } from "../../../state/context";

@ -5,7 +5,7 @@ import { gitPluginContext } from "../gitui";
import { default as dateFormat } from "dateformat";
import { RemotesDetailsNavigation } from "../navigation/remotesdetails";
import { Accordion } from "react-bootstrap";
import { remote } from "../../types";
import { remote } from "@remix-api";
import { RemoteBranchDetails } from "./branches/remotebranchedetails";
export interface RemoteSelectProps {

@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import { Alert, Button } from "react-bootstrap";
import { gitActionsContext } from "../../state/context";
import { repository } from "../../types";
import { repository } from "@remix-api";
import { gitPluginContext } from "../gitui";
import Select from 'react-select'
import { selectStyles, selectTheme } from "../../types/styles";

@ -1,4 +1,4 @@
import { commitChange, fileStatusResult, sourceControlGroup } from "../../../types";
import { fileStatusResult, sourceControlGroup } from "../../../types";
import React from "react";
import path from "path";
import { gitActionsContext, pluginActionsContext } from "../../../state/context";
@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faGlobe } from "@fortawesome/free-solid-svg-icons";
import { SourceControlItemButtons } from "./sourcontrolitembuttons";
import { removeSlash } from "../../../utils";
import { commitChange } from "@remix-api";
export interface SourceControlItemProps {
file: fileStatusResult;

@ -1,4 +1,4 @@
import { commitChange, fileStatusResult, sourceControlGroup } from "../../../types";
import { fileStatusResult, sourceControlGroup } from "../../../types";
import React from "react";
import path from "path";
import { gitActionsContext, pluginActionsContext } from "../../../state/context";

@ -1,4 +1,4 @@
export * from './types'
export { GitUI } from './components/gitui'
export { commitChange, commitChangeType, remote, branch } from './types'
export { commitChange, commitChangeType, remote, branch } from '@remix-api'
export * from './types/styles'

@ -1,13 +1,13 @@
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git";
import React from "react";
import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails, setCurrenHead } from "../state/gitpayload";
import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types';
import { GitHubUser, gitActionDispatch, statusMatrixType, gitState, gitLog, fileStatusResult, userEmails } from '../types';
import { removeSlash } from "../utils";
import { disableCallBacks, enableCallBacks } from "./listeners";
import { ModalTypes } from "@remix-ui/app";
import { setFileDecorators } from "./pluginActions";
import { Plugin } from "@remixproject/engine";
import { CustomRemixApi } from "@remix-api";
import { addInputType, branch, branchDifference, checkoutInputType, cloneInputType, commitChange, CustomRemixApi, fetchInputType, pullInputType, pushInputType, remote, rmInputType } from "@remix-api";
import { file } from "jszip";
export const fileStatuses = [
@ -54,7 +54,7 @@ export const getBranches = async () => {
}
export const getRemotes = async () => {
const remotes: remote[] = await plugin.call('dgitApi', "remotes");
const remotes: remote[] = await plugin.call('dgitApi', 'remotes');
dispatch(setRemotes(remotes));
}
@ -226,7 +226,7 @@ export const addall = async (files: fileStatusResult[]) => {
}
}
export const add = async (filepath: addInput) => {
export const add = async (filepath: addInputType) => {
try {
if (typeof filepath.filepath === "string") {
filepath.filepath = removeSlash(filepath.filepath)
@ -252,7 +252,7 @@ const getLastCommmit = async () => {
}
}
export const rm = async (args: rmInput) => {
export const rm = async (args: rmInputType) => {
await plugin.call('dgitApi', 'rm', {
filepath: removeSlash(args.filepath),
});
@ -288,7 +288,7 @@ export const checkoutfile = async (filename: string) => {
}
}
export const checkout = async (cmd: checkoutInput) => {
export const checkout = async (cmd: checkoutInputType) => {
await disableCallBacks();
await plugin.call('fileManager', 'closeAllFiles')
@ -705,6 +705,7 @@ export const diff = async (commitChange: commitChange) => {
}
export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => {
console.log('getCommitChanges', oid1, oid2, branch, remote)
try {
let log
try {
@ -717,6 +718,7 @@ export const getCommitChanges = async (oid1: string, oid2: string, branch?: bran
console.log(e, 'log error')
}
if (log) {
console.log('log', log)
const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2)
if (!foundCommit && remote) {

@ -65,7 +65,20 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
loadFiles()
})
});
plugin.on('fs', 'workingDirChanged', async (path: string) => {
loadFileQueue.enqueue(async () => {
loadFiles()
})
loadFileQueue.enqueue(async () => {
gitlog()
})
loadFileQueue.enqueue(async () => {
getBranches()
})
loadFileQueue.enqueue(async () => {
getRemotes()
})
})
plugin.on("filePanel", "setWorkspace", async (x: any) => {
gitDispatch(setCanUseApp(x && !x.isLocalhost && x.name))
loadFileQueue.enqueue(async () => {

@ -1,9 +1,9 @@
import { commitChange, fileStatusResult, gitActionDispatch, gitState } from "../types"
import { fileStatusResult, gitActionDispatch, gitState } from "../types"
import { fileDecoration, fileDecorationType } from "@remix-ui/file-decorators"
import { removeSlash } from "../utils"
import { getFilesByStatus } from "./fileHelpers"
import { CustomRemixApi } from "@remix-api";
import { commitChange, CustomRemixApi } from "@remix-api";
import { Plugin } from "@remixproject/engine";
let plugin: Plugin<any, CustomRemixApi>, gitDispatch: React.Dispatch<gitActionDispatch>, loaderDispatch: React.Dispatch<any>

@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
import { branch, branchDifference, commitChange, fileStatusResult, GitHubUser, gitLog, pagedCommits, remote, remoteBranch, repository, userEmails } from "../types"
import { fileStatusResult, GitHubUser, gitLog, userEmails } from "../types"
import { branch, branchDifference, commitChange, pagedCommits, remote, remoteBranch, repository } from '@remix-api'
export interface ActionPayloadTypes {
FILE_STATUS: fileStatusResult[],
FILE_STATUS_MERGE: fileStatusResult[]

@ -1,12 +1,13 @@
import { branch, addInputType, checkoutInputType, cloneInputType, commitChange, fetchInputType, pullInputType, pushInputType, remote, rmInputType } from "@remix-api"
import { ReadCommitResult } from "isomorphic-git"
import React from "react"
import { addInput, branch, checkoutInput, cloneInputType, commitChange, fetchInputType, fileStatusResult, gitLog, gitState, pullInputType, pushInputType, remote, rmInput } from "../types"
import { fileStatusResult, gitLog, gitState } from "../types"
export interface gitActions {
removeRemote(remote: remote): void
clone(input: cloneInputType): Promise<void>
add(input: addInput): Promise<void>
rm(input: rmInput): Promise<void>
add(input: addInputType): Promise<void>
rm(input: rmInputType): Promise<void>
commit(message: string): Promise<any>
addall(files: fileStatusResult[]): Promise<void>
push(input: pushInputType): Promise<void>
@ -14,7 +15,7 @@ export interface gitActions {
fetch(input: fetchInputType): Promise<void>
repositories(): Promise<any>
checkoutfile(file: string): Promise<void>
checkout(input: checkoutInput): Promise<void>
checkout(input: checkoutInputType): Promise<void>
createBranch(branch: string): Promise<void>
remoteBranches(owner: string, repo: string): Promise<any>
getCommitChanges(oid1: string, oid2: string, branch?: branch, remote?: remote): Promise<commitChange[] | boolean>

@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
import { GitHubUser, branch, commitChange, fileStatusResult, remote, pagedCommits, branchDifference, gitLog, repository, userEmails } from "../types"
import { Endpoints } from "@octokit/types"
import { GitHubUser, fileStatusResult, gitLog, userEmails } from "../types"
import { repository, pagedCommits, branch, remote, commitChange, branchDifference } from "@remix-api"
export const fileStatus = (files: fileStatusResult[]) => {
return {

@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers"
import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction, setUpstreamAction } from "../types"
import { commitChange } from "@remix-api"
import { allChangedButNotStagedFiles, getFilesByStatus } from "../lib/fileHelpers"
import { defaultGitState, fileStatusResult, gitState } from "../types"
import { Actions } from "./actions"
export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => {

@ -1,156 +1,9 @@
import { Endpoints } from "@octokit/types"
import { IRemixApi } from "@remixproject/plugin-api"
import { LibraryProfile, StatusEvents } from "@remixproject/plugin-utils"
import { CommitObject, ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git"
import { branch, branchDifference, commitChange, pagedCommits, remote, remoteBranch, repository, syncStatus } from "@remix-api"
import { ReadCommitResult } from "isomorphic-git"
export type GitHubUser = Partial<Endpoints["GET /user"]["response"]['data']>
export type userEmails = Endpoints["GET /user/emails"]["response"]["data"]
export interface IGitApi {
events: {
"checkout": () => void
"clone": () => void
"add": () => void
"rm": () => void
"commit": () => void
"branch": () => void
"init": () => void
} & StatusEvents,
methods: {
getCommitChanges(oid1: string, oid2: string): Promise<commitChange[]>
repositories(input: repositoriesInput): Promise<repository[]>
clone(input: cloneInputType): Promise<any>
branches(input?: branchesInput): Promise<branch[]>,
remotes(): Promise<remote[]>,
log(cmd: { ref: string }): Promise<ReadCommitResult[]>,
remotecommits(input: remoteCommitsInputType): Promise<pagedCommits[]>
fetch(input: fetchInputType): Promise<any>
pull(input: pullInputType): Promise<any>
push(input: pushInputType): Promise<any>
currentbranch(input?: currentBranchInput): Promise<branch>
branch(input: branchInputType): Promise<void>
checkout(input: checkoutInput): Promise<void>
add(input: addInput): Promise<void>
rm(input: rmInput): Promise<void>
resolveref(input: resolveRefInput): Promise<string>
readblob(input: readBlobInput): Promise<ReadBlobResult>
commit(input: commitInput): Promise<string>
addremote(input: remote): Promise<void>
delremote(input: remote): Promise<void>
status(input?: statusInput): Promise<Array<StatusRow>>
compareBranches(input: compareBranchesInput): Promise<branchDifference>
init(input?: initInput): Promise<void>
updateSubmodules: (input: updateSubmodulesInput) => Promise<void>
}
}
export type initInput = {
defaultBranch: string
}
export type updateSubmodulesInput = {
dir?: string
token?: string
}
export type remoteCommitsInputType = {
owner: string, repo: string, token: string, branch: string, length: number, page: number
}
export type compareBranchesInput = {
branch: branch, remote: remote
}
export type fetchInputType = {
remote: remote,
ref?: branch,
remoteRef?: branch,
depth?: number,
singleBranch?: boolean,
relative?: boolean,
quiet?: boolean
}
export type pullInputType = {
remote: remote, ref: branch, remoteRef?: branch
}
export type pushInputType = {
remote: remote, ref: branch, remoteRef?: branch, force?: boolean
}
export type branchInputType = {
ref: string,
checkout?: boolean
refresh?: boolean
force?: boolean
}
export type currentBranchInput = {
fs: any,
dir: string
}
export type checkoutInput = {
ref: string,
force?: boolean,
remote?: string
refresh?: boolean
fetch?: boolean
}
export type addInput = {
filepath: string | string[]
}
export type rmInput = {
filepath: string
}
export type resolveRefInput = {
ref: string
}
export type readBlobInput = {
oid: string,
filepath: string
}
export type commitInput = {
author: {
name: string,
email: string,
},
message: string,
}
export type branchesInput = {
fs?: any
dir?: string
}
export interface cloneInputType {
url: string,
branch?: string,
depth?: number,
singleBranch?: boolean
workspaceName?: string
workspaceExists?: boolean
token?: string
}
export interface repositoriesInput { token: string, page?: number, per_page?: number }
export interface statusInput { ref: string, filepaths?: string[] }
export const dGitProfile: LibraryProfile<IGitApi> = {
name: 'dgitApi',
methods: ['clone', 'branches', 'remotes', 'getCommitChanges', 'log', 'remotecommits'],
}
export interface customGitApi extends IRemixApi {
dgit: IGitApi
}
export type gitState = {
currentBranch: branch
currentHead: string
@ -193,19 +46,6 @@ export type gitLog = {
export type remoteBranchIdentifier = `${string}/${string}`
export type branchDifference = {
uniqueHeadCommits: ReadCommitResult[],
uniqueRemoteCommits: ReadCommitResult[],
}
export type pagedCommits = {
page: number,
perPage: number,
total: number,
hasNextPage: boolean,
commits: ReadCommitResult[]
}
export type loaderState = {
branches: boolean
remotes: boolean
@ -214,57 +54,6 @@ export type loaderState = {
plugin: boolean
}
export type commitChangeTypes = {
"deleted": "D"
"modified": "M"
"added": "A",
"unknown": "?"
}
export enum syncStatus {
"sync" = "sync",
"publishBranch" = "publishBranch",
"none" = "none",
}
export type commitChangeType = keyof commitChangeTypes
export type commitChange = {
type: commitChangeType
path: string,
hashModified: string,
hashOriginal: string,
original?: string,
modified?: string,
readonly?: boolean
}
export type repository = {
name: string
html_url: string
owner: {
login: string
},
full_name: string
default_branch: string
id: number
url: string
}
export type branch = {
name: string
remote: remote
}
export type remote = {
name: string
url: string
}
export type remoteBranch = {
name: string
}
export const defaultGitState: gitState = {
currentBranch: { name: "", remote: { name: "", url: "" } },
currentHead: "",

@ -42,10 +42,10 @@ import { ROOT_PATH, slitherYml, solTestYml, tsSolTestYml } from '../utils/consta
import { IndexedDBStorage } from '../../../../../../apps/remix-ide/src/app/files/filesystems/indexedDB'
import { getUncommittedFiles } from '../utils/gitStatusFilter'
import { AppModal, ModalTypes } from '@remix-ui/app'
import { branch, cloneInputType, IGitApi } from '@remix-ui/git'
import * as templates from '@remix-project/remix-ws-templates'
import { Plugin } from "@remixproject/engine";
import { CustomRemixApi } from '@remix-api'
import { CustomRemixApi, branch, cloneInputType } from '@remix-api'
declare global {
interface Window {
@ -204,6 +204,7 @@ export const createWorkspace = async (
}, 5000)
} else if (!isEmpty && !(isGitRepo && createCommit)) await loadWorkspacePreset(workspaceTemplateName, opts)
cb && cb(null, workspaceName)
if (workspaceTemplateName === 'semaphore' || workspaceTemplateName === 'hashchecker' || workspaceTemplateName === 'rln') {
const isCircomActive = await plugin.call('manager', 'isActive', 'circuit-compiler')
if (!isCircomActive) await plugin.call('manager', 'activatePlugin', 'circuit-compiler')
@ -508,6 +509,7 @@ export const switchToWorkspace = async (name: string) => {
await plugin.fileProviders.workspace.setWorkspace(name)
await plugin.setWorkspace({ name, isLocalhost: false })
const isGitRepo = await plugin.fileManager.isGitRepo()
dispatch(setMode('browser'))
dispatch(setCurrentWorkspace({ name, isGitRepo }))
dispatch(setReadOnlyMode(false))
@ -665,10 +667,9 @@ export const cloneRepository = async (url: string) => {
dispatch(cloneRepositoryRequest())
promise
.then(async () => {
if (!plugin.registry.get('platform').api.isDesktop()) {
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
}
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
await fetchWorkspaceDirectory(ROOT_PATH)
const workspacesPath = plugin.fileProviders.workspace.workspacesPath
const branches = await getGitRepoBranches(workspacesPath + '/' + repoName)
@ -753,7 +754,7 @@ export const getGitRepoCurrentBranch = async (workspaceName: string) => {
}
export const showAllBranches = async () => {
if (plugin.registry.get('platform').api.isDesktop()) return
const isActive = await plugin.call('manager', 'isActive', 'dgit')
if (!isActive) await plugin.call('manager', 'activatePlugin', 'dgit')
plugin.call('menuicons', 'select', 'dgit')

Loading…
Cancel
Save