run builtin

pull/4991/head
Your Name 4 months ago
parent 772544ced6
commit aa0d1740cc
  1. 20
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 2
      apps/remixdesktop/package.json
  3. 2
      apps/remixdesktop/run_ci_test.sh
  4. 6
      apps/remixdesktop/run_git_ui_isogit_tests.sh
  5. 15
      apps/remixdesktop/src/plugins/isoGitPlugin.ts
  6. 2
      apps/remixdesktop/test/tests/app/git-ui.test.ts
  7. 2
      apps/remixdesktop/test/tests/app/git-ui_2.test.ts
  8. 2
      apps/remixdesktop/test/tests/app/git-ui_3.test.ts
  9. 1
      apps/remixdesktop/test/tests/app/git.test.ts
  10. 18
      libs/remix-git/src/isogit.ts
  11. 3
      libs/remix-ui/git/src/components/gitui.tsx
  12. 10
      libs/remix-ui/git/src/components/panels/version.tsx
  13. 8
      libs/remix-ui/git/src/lib/listeners.ts
  14. 1
      libs/remix-ui/git/src/state/actions.ts
  15. 7
      libs/remix-ui/git/src/state/gitpayload.ts
  16. 412
      libs/remix-ui/git/src/state/gitreducer.tsx
  17. 4
      libs/remix-ui/git/src/types/index.ts

@ -339,21 +339,13 @@ class DGitProvider extends Plugin<any, CustomRemixApi> {
async clone(input: cloneInputType) {
if ((Registry.getInstance().get('platform').api.isDesktop())) {
const folder = await this.call('fs', 'selectFolder', null, 'Select or create a folder to clone the repository in', 'Select as Repository Destination')
if (!folder) return false
const cmd = {
url: input.url,
singleBranch: input.singleBranch,
ref: input.branch,
depth: input.depth || 10,
dir: folder,
input
}
this.call('terminal', 'logHtml', `Cloning ${input.url}... please wait...`)
try {
const result = await this.call('isogit', 'clone', cmd)
this.call('fs', 'openWindow', folder)
return result
const folder = await this.call('fs', 'selectFolder', null, 'Select or create a folder to clone the repository in', 'Select as Repository Destination')
if (!folder) return false
input.dir = folder
input.depth = input.depth || 10
const result = await this.call('isogit', 'clone', input)
this.call('fs' as any, 'openWindow', folder)
} catch (e) {
this.call('notification', 'alert', {
id: 'dgitAlert',

@ -29,7 +29,7 @@
"installRipGrepMacOXarm64": "rm -rf node_modules/@vscode/ripgrep/bin && npm_config_arch=arm64 node node_modules/@vscode/ripgrep/lib/postinstall.js",
"postinstall": "electron-builder install-app-deps",
"test": "yarn run build:e2e && nightwatch --config build-e2e/remixdesktop/test/nighwatch.app.js",
"test:isogit": "yarn run test --useIsoGit --test build-e2e/remixdesktop/test/tests/app/git.test.js",
"test:isogit": "yarn run test --useIsoGit",
"test:offline": "yarn run test --useOffline --test build-e2e/remixdesktop/test/tests/app/offline.test.js",
"build:e2e": "tsc -p tsconfig.e2e.json"
},

@ -8,7 +8,7 @@ for TESTFILE in $TESTFILES; do
done
if [ "$CIRCLE_NODE_INDEX" -eq 0 ]; then
yarn test:isogit
sh ./run_git_ui_isogit_tests.sh
elif [ "$CIRCLE_NODE_INDEX" -eq 1 ]; then
yarn test:offline
fi

@ -0,0 +1,6 @@
#!/bin/bash
for testfile in build-e2e/remixdesktop/test/tests/app/git*.js
do
yarn test:isogit --test $testfile
done

@ -44,7 +44,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
this.onload(async () => {
this.on('fs' as any, 'workingDirChanged', async (path: string) => {
this.workingDir = path
this.gitIsInstalled = await gitProxy.version() ? true : false
this.gitIsInstalled = await gitProxy.version() && !useIsoGit ? true : false
})
this.workingDir = await this.call('fs' as any, 'getWorkingDir')
this.gitIsInstalled = await gitProxy.version() && !useIsoGit ? true : false
@ -52,7 +52,7 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
}
async version() {
return gitProxy.version()
return this.gitIsInstalled? gitProxy.version(): 'built-in'
}
async getGitConfig() {
@ -266,23 +266,16 @@ class IsoGitPluginClient extends ElectronBasePluginClient {
if (this.gitIsInstalled) {
try {
this.call('terminal' as any, 'log', 'Cloning using git... please wait.')
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(),
...cmd,
...parseInput(cmd.input),
dir: cmd.dir || this.workingDir
})
const clone = await isoGit.clone(cmd, await this.getGitConfig(), this)
return clone
*/
} catch (e) {
console.log('CLONE ERROR', e)
throw e

@ -13,6 +13,7 @@ let gitserver: ChildProcess
const tests = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
browser.hideToolTips()
done()
},
after: function (browser: NightwatchBrowser) {
@ -48,6 +49,7 @@ const tests = {
console.log(result.value)
browser.switchWindow(result.value[1])
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]')
.hideToolTips()
})
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]')
},

@ -13,6 +13,7 @@ let gitserver: ChildProcess
const tests = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
browser.hideToolTips()
done()
},
after: function (browser: NightwatchBrowser) {
@ -48,6 +49,7 @@ const tests = {
console.log(result.value)
browser.switchWindow(result.value[1])
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]')
.hideToolTips()
})
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]')
},

@ -13,6 +13,7 @@ let gitserver: ChildProcess
const tests = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
browser.hideToolTips()
done()
},
after: function (browser: NightwatchBrowser) {
@ -48,6 +49,7 @@ const tests = {
console.log(result.value)
browser.switchWindow(result.value[1])
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]')
.hideToolTips()
})
.waitForElementVisible('*[data-id="treeViewLitreeViewItemREADME.md"]')
},

@ -23,6 +23,7 @@ module.exports = {
browser.switchWindow(result.value[1])
.waitForElementVisible('*[data-id="treeViewLitreeViewItem.git"]')
})
.pause()
.end()
}
}

@ -1,4 +1,4 @@
import { GitHubUser, author, branch, commitChange, compareBranchesInput, currentBranchInput, fetchInputType, isoGitFSConfig, isoGitProxyConfig, pullInputType, pushInputType, remote, userEmails } from "@remix-api"
import { GitHubUser, author, branch, cloneInputType, commitChange, compareBranchesInput, currentBranchInput, fetchInputType, isoGitFSConfig, isoGitProxyConfig, pullInputType, pushInputType, remote, userEmails } from "@remix-api"
import git from 'isomorphic-git'
import {
Plugin
@ -120,6 +120,19 @@ const fetch = async (input: fetchInputType, fsConfig: isoGitFSConfig, plugin: Pl
return await git.fetch({ ...fsConfig, ...cmd, ...proxy })
}
const clone = async (input: cloneInputType, fsConfig: isoGitFSConfig, plugin: Plugin | ElectronBasePluginClient) => {
const proxy = await isoGit.addIsomorphicGitProxyConfig(input, plugin)
const cmd = {
url: input.url,
singleBranch: input.singleBranch,
ref: input.branch,
depth: input.depth || 10,
dir: input.dir,
input
}
await git.clone({ ...fsConfig, ...cmd, ...proxy })
}
const getAuthor = async (input, plugin: any) => {
const author: author = {
name: '',
@ -325,5 +338,6 @@ export const isoGit = {
push,
pull,
fetch,
getGitHubUser
getGitHubUser,
clone
}

@ -35,6 +35,7 @@ import { CustomRemixApi } from "@remix-api";
import { Plugin } from "@remixproject/engine";
import { Disabled } from './disabled'
import { platformContext } from '@remix-ui/app'
import { Version } from './panels/version'
export const gitPluginContext = React.createContext<gitState>(defaultGitState)
export const loaderContext = React.createContext<loaderState>(defaultLoaderState)
@ -179,6 +180,7 @@ export const GitUI = (props: IGitUi) => {
{setup && !needsInit ? <Setup></Setup> : null}
{needsInit ? <Init></Init> : null}
{!setup && !needsInit ?
<>
<Accordion activeKey={activePanel} defaultActiveKey="0">
<SourceControlNavigation eventKey="0" activePanel={activePanel} callback={setActivePanel} />
@ -239,6 +241,7 @@ export const GitUI = (props: IGitUi) => {
</Accordion.Collapse>
</Accordion>
<Version/></>
: null}
</pluginActionsContext.Provider>
</gitActionsContext.Provider>

@ -0,0 +1,10 @@
import React, { useEffect, useState } from 'react'
import { gitPluginContext } from '../gitui'
export const Version = () => {
const context = React.useContext(gitPluginContext)
return (
<div>
<p>{context.version.includes('version') ? context.version : `Git version: ${context.version}` }</p>
</div>
)
}

@ -1,6 +1,6 @@
import React from "react";
import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails, setDesktopWorkingDir } from "../state/gitpayload";
import { setCanUseApp, setLoading, setRepoName, setGItHubToken, setLog, setGitHubUser, setUserEmails, setDesktopWorkingDir, setVersion } from "../state/gitpayload";
import { gitActionDispatch } from "../types";
import { Plugin } from "@remixproject/engine";
import { getBranches, getFileStatusMatrix, loadGitHubUserFromToken, getRemotes, gitlog, setPlugin } from "./gitactions";
@ -71,6 +71,9 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
console.log('workingDirChanged', path)
gitDispatcher(setDesktopWorkingDir(path))
gitDispatch(setCanUseApp(path ? true : false))
const version = await plugin.call('dgitApi', 'version')
console.log(version)
gitDispatch(setVersion(version))
loadFileQueue.enqueue(async () => {
loadFiles()
})
@ -91,6 +94,9 @@ export const setCallBacks = (viewPlugin: Plugin, gitDispatcher: React.Dispatch<g
if (platform == appPlatformTypes.desktop) {
const workingDir = await plugin.call('fs', 'getWorkingDir')
gitDispatch(setCanUseApp(workingDir? true : false))
const version = await plugin.call('dgitApi', 'version')
console.log(version)
gitDispatch(setVersion(version))
} else {
gitDispatch(setCanUseApp(x && !x.isLocalhost && x.name))
}

@ -43,6 +43,7 @@ export interface ActionPayloadTypes {
CLEAR_LOG: void
SET_USER_EMAILS: userEmails
DESKTOP_SET_WORKING_DIR: string
SET_VERSION: string
}
export interface Action<T extends keyof ActionPayloadTypes> {

@ -225,3 +225,10 @@ export const setDesktopWorkingDir = (dir: string) => {
payload: dir
}
}
export const setVersion = (version: string) => {
return {
type: 'SET_VERSION',
payload: version
}
}

@ -6,208 +6,216 @@ import { Actions } from "./actions"
export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitState => {
switch (action.type) {
case 'FILE_STATUS':
return {
...state,
fileStatusResult: action.payload,
staged: getFilesByStatus("staged", action.payload),
modified: getFilesByStatus("modified", action.payload),
untracked: getFilesByStatus("untracked", action.payload),
deleted: getFilesByStatus("deleted", action.payload),
allchangesnotstaged: allChangedButNotStagedFiles(action.payload)
}
case 'FILE_STATUS_MERGE':
action.payload.map((fileStatusResult: fileStatusResult) => {
const file = state.fileStatusResult.find(stateFile => {
return stateFile.filename === fileStatusResult.filename
case 'FILE_STATUS':
return {
...state,
fileStatusResult: action.payload,
staged: getFilesByStatus("staged", action.payload),
modified: getFilesByStatus("modified", action.payload),
untracked: getFilesByStatus("untracked", action.payload),
deleted: getFilesByStatus("deleted", action.payload),
allchangesnotstaged: allChangedButNotStagedFiles(action.payload)
}
case 'FILE_STATUS_MERGE':
action.payload.map((fileStatusResult: fileStatusResult) => {
const file = state.fileStatusResult.find(stateFile => {
return stateFile.filename === fileStatusResult.filename
})
if (file) {
file.status = fileStatusResult.status
file.statusNames = fileStatusResult.statusNames
}
})
if (file) {
file.status = fileStatusResult.status
file.statusNames = fileStatusResult.statusNames
}
})
return {
...state,
staged: getFilesByStatus("staged", state.fileStatusResult),
modified: getFilesByStatus("modified", state.fileStatusResult),
untracked: getFilesByStatus("untracked", state.fileStatusResult),
deleted: getFilesByStatus("deleted", state.fileStatusResult),
allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult)
}
case 'SET_COMMITS':
return {
...state,
commits: action.payload,
localCommitCount: action.payload.length
}
case 'SET_BRANCHES':
return {
...state,
branches: action.payload
}
case 'SET_CURRENT_BRANCH':
return {
...state,
currentBranch: action.payload
}
case 'SET_CURRENT_HEAD':
return {
...state,
currentHead: action.payload
}
case 'SET_CAN_USE_APP':
return {
...state,
canUseApp: action.payload
}
case 'SET_REPO_NAME':
return {
...state,
reponame: action.payload
}
case 'SET_LOADING':
return {
...state,
loading: action.payload
}
case 'SET_REPOS':
return {
...state,
repositories: action.payload
}
case 'SET_REMOTE_BRANCHES':
return {
...state,
remoteBranches: action.payload
}
case 'SET_CAN_COMMIT':
return {
...state,
canCommit: action.payload
}
case 'SET_REMOTES':
return {
...state,
remotes: action.payload
}
case 'SET_UPSTREAM':
return {
...state,
upstream: action.payload
}
case 'SET_COMMIT_CHANGES':
action.payload.forEach((change: commitChange) => {
state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change)
})
return {
...state,
commitChanges: [...state.commitChanges]
}
case 'RESET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) {
delete state.remoteBranchCommits[action.payload.branch.name]
}
return {
...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) {
state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits)
} else {
state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits
}
return {
...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_LOCAL_BRANCH_COMMITS':
state.localBranchCommits[action.payload.branch.name] = action.payload.commits
return {
...state,
localBranchCommits: { ...state.localBranchCommits }
}
case 'SET_BRANCH_DIFFERENCES':
state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference
return {
...state,
branchDifferences: { ...state.branchDifferences }
}
case 'SET_GITHUB_USER':
return {
...state,
gitHubUser: action.payload
}
case 'SET_GITHUB_ACCESS_TOKEN':
return {
...state,
gitHubAccessToken: action.payload
}
case 'SET_SCOPES':
return {
...state,
gitHubScopes: action.payload
}
case 'SET_USER_EMAILS':
return {
...state,
userEmails: action.payload
}
case 'SET_DEFAULT_REMOTE':
return {
...state,
defaultRemote: action.payload
}
case 'SET_LOG':
if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) {
return {
...state,
log: [...state.log]
}
}
return {
...state,
log: [...state.log, action.payload]
}
case 'CLEAR_LOG':
return {
...state,
log: []
}
case 'DESKTOP_SET_WORKING_DIR':
return {
...state,
desktopWorkingDir: action.payload
}
return {
...state,
staged: getFilesByStatus("staged", state.fileStatusResult),
modified: getFilesByStatus("modified", state.fileStatusResult),
untracked: getFilesByStatus("untracked", state.fileStatusResult),
deleted: getFilesByStatus("deleted", state.fileStatusResult),
allchangesnotstaged: allChangedButNotStagedFiles(state.fileStatusResult)
}
case 'SET_COMMITS':
return {
...state,
commits: action.payload,
localCommitCount: action.payload.length
}
case 'SET_BRANCHES':
return {
...state,
branches: action.payload
}
case 'SET_CURRENT_BRANCH':
return {
...state,
currentBranch: action.payload
}
case 'SET_CURRENT_HEAD':
return {
...state,
currentHead: action.payload
}
case 'SET_CAN_USE_APP':
return {
...state,
canUseApp: action.payload
}
case 'SET_REPO_NAME':
return {
...state,
reponame: action.payload
}
case 'SET_LOADING':
return {
...state,
loading: action.payload
}
case 'SET_REPOS':
return {
...state,
repositories: action.payload
}
case 'SET_REMOTE_BRANCHES':
return {
...state,
remoteBranches: action.payload
}
case 'SET_CAN_COMMIT':
return {
...state,
canCommit: action.payload
}
case 'SET_REMOTES':
return {
...state,
remotes: action.payload
}
case 'SET_UPSTREAM':
return {
...state,
upstream: action.payload
}
case 'SET_COMMIT_CHANGES':
action.payload.forEach((change: commitChange) => {
state.commitChanges.find((c) => c.hashModified === change.hashModified && c.hashOriginal === change.hashOriginal && c.path === change.path) ? null : state.commitChanges.push(change)
})
return {
...state,
commitChanges: [...state.commitChanges]
}
case 'RESET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) {
delete state.remoteBranchCommits[action.payload.branch.name]
}
return {
...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_REMOTE_BRANCH_COMMITS':
if (state.remoteBranchCommits[action.payload.branch.name]) {
state.remoteBranchCommits[action.payload.branch.name].push(...action.payload.commits)
} else {
state.remoteBranchCommits[action.payload.branch.name] = action.payload.commits
}
return {
...state,
remoteBranchCommits: { ...state.remoteBranchCommits }
}
case 'SET_LOCAL_BRANCH_COMMITS':
state.localBranchCommits[action.payload.branch.name] = action.payload.commits
return {
...state,
localBranchCommits: { ...state.localBranchCommits }
}
case 'SET_BRANCH_DIFFERENCES':
state.branchDifferences[`${action.payload.remote.name}/${action.payload.branch.name}`] = action.payload.branchDifference
return {
...state,
branchDifferences: { ...state.branchDifferences }
}
case 'SET_GITHUB_USER':
return {
...state,
gitHubUser: action.payload
}
case 'SET_GITHUB_ACCESS_TOKEN':
return {
...state,
gitHubAccessToken: action.payload
}
case 'SET_SCOPES':
return {
...state,
gitHubScopes: action.payload
}
case 'SET_USER_EMAILS':
return {
...state,
userEmails: action.payload
}
case 'SET_DEFAULT_REMOTE':
return {
...state,
defaultRemote: action.payload
}
case 'SET_LOG':
if (state.log.length > 0 && state.log[[...state.log].length - 1].message === action.payload.message) {
return {
...state,
log: [...state.log]
}
}
return {
...state,
log: [...state.log, action.payload]
}
case 'CLEAR_LOG':
return {
...state,
log: []
}
case 'DESKTOP_SET_WORKING_DIR':
return {
...state,
desktopWorkingDir: action.payload
}
case 'SET_VERSION':
return {
...state,
version: action.payload
}
}
}

@ -37,6 +37,7 @@ export type gitState = {
gitHubAccessToken: string
log: gitLog[]
desktopWorkingDir?: string
version: string
}
export type gitLog = {
type: 'error' | 'warning' | 'info' | 'success',
@ -87,7 +88,8 @@ export const defaultGitState: gitState = {
gitHubScopes: [],
gitHubAccessToken: "",
log: [],
desktopWorkingDir: null
desktopWorkingDir: null,
version: ""
}
export const defaultLoaderState: loaderState = {

Loading…
Cancel
Save