diff --git a/apps/remix-ide/src/app/files/dgitProvider.ts b/apps/remix-ide/src/app/files/dgitProvider.ts index 669a28e78b..12c9d35693 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.ts +++ b/apps/remix-ide/src/app/files/dgitProvider.ts @@ -18,8 +18,11 @@ import {Registry} from '@remix-project/remix-lib' import { Octokit, App } from "octokit" import { OctokitResponse } from '@octokit/types' import { Endpoints } from "@octokit/types" -import { commitChange, GitHubUser, RateLimit } from '@remix-ui/git' - +import { IndexedDBStorage } from './filesystems/indexedDB' +import { GitHubUser, RateLimit, branch, commitChange, remote } from '@remix-ui/git' +declare global { + interface Window { remixFileSystemCallback: IndexedDBStorage; remixFileSystem: any; } +} const profile = { name: 'dGitProvider', displayName: 'Decentralized git', @@ -338,10 +341,32 @@ class DGitProvider extends Plugin { const defaultConfig = await this.getGitConfig() const cmd = config ? defaultConfig ? { ...defaultConfig, ...config } : config : defaultConfig const name = await git.currentBranch(cmd) + console.log('current branch', name) + 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 = { remote: remoteName, url: remoteUrl } + } + + } catch (e) { + // do nothing + } - return name + return { + remote: remote, + name: name || '' + } } catch (e) { - return '' + return undefined } } @@ -746,7 +771,7 @@ class DGitProvider extends Plugin { const files = await this.getDirectory('/') this.filesToSend = [] for (const file of files) { - const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`) + const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`, null) const ob = { path: file, content: c @@ -760,108 +785,6 @@ class DGitProvider extends Plugin { return r.cid.string } - async pin(pinataApiKey, pinataSecretApiKey) { - const workspace = await this.call('filePanel', 'getCurrentWorkspace') - const files = await this.getDirectory('/') - this.filesToSend = [] - - const data = new FormData() - for (const file of files) { - const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`) - data.append('file', new Blob([c]), `base/${file}`) - } - // get last commit data - let ob - try { - const commits = await this.log({ ref: 'HEAD' }) - ob = { - ref: commits[0].oid, - message: commits[0].commit.message, - commits: JSON.stringify(commits.map((commit) => { - return { - oid: commit.oid, - commit: { - parent: commit.commit?.parent, - tree: commit.commit?.tree, - message: commit.commit?.message, - committer: { - timestamp: commit.commit?.committer?.timestamp - } - } - } - })) - } - } catch (e) { - ob = { - ref: 'no commits', - message: 'no commits' - } - } - const today = new Date() - const metadata = JSON.stringify({ - name: `remix - ${workspace.name} - ${today.toLocaleString()}`, - keyvalues: ob - }) - const pinataOptions = JSON.stringify({ - wrapWithDirectory: false - }) - data.append('pinataOptions', pinataOptions) - data.append('pinataMetadata', metadata) - const url = 'https://api.pinata.cloud/pinning/pinFileToIPFS' - try { - const result = await axios - .post(url, data, { - maxBodyLength: 'Infinity', - headers: { - 'Content-Type': `multipart/form-data; boundary=${(data as any)._boundary}`, - pinata_api_key: pinataApiKey, - pinata_secret_api_key: pinataSecretApiKey - } - } as any).catch((e) => { - console.log(e) - }) - // also commit to remix IPFS for availability after pinning to Pinata - return await this.export(this.remixIPFS) || (result as any).data.IpfsHash - } catch (error) { - throw new Error(error) - } - } - - async pinList(pinataApiKey, pinataSecretApiKey) { - const url = 'https://api.pinata.cloud/data/pinList?status=pinned' - try { - const result = await axios - .get(url, { - maxBodyLength: 'Infinity', - headers: { - pinata_api_key: pinataApiKey, - pinata_secret_api_key: pinataSecretApiKey - } - } as any).catch((e) => { - console.log('Pinata unreachable') - }) - return (result as any).data - } catch (error) { - throw new Error(error) - } - } - - async unPin(pinataApiKey, pinataSecretApiKey, hashToUnpin) { - const url = `https://api.pinata.cloud/pinning/unpin/${hashToUnpin}` - try { - await axios - .delete(url, { - headers: { - pinata_api_key: pinataApiKey, - pinata_secret_api_key: pinataSecretApiKey - } - }) - return true - } catch (error) { - throw new Error(error) - } - } - async importIPFSFiles(config, cid, workspace) { const ipfs = IpfsHttpClient(config) let result = false @@ -882,7 +805,7 @@ class DGitProvider extends Plugin { await this.createDirectories(`${workspace.absolutePath}/${dir}`) } catch (e) { throw new Error(e) } try { - await window.remixFileSystem.writeFile(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array()) + await window.remixFileSystem.writeFile(`${workspace.absolutePath}/${file.path}`, Buffer.concat(content) || new Uint8Array(), null) } catch (e) { throw new Error(e) } } } catch (e) { @@ -948,7 +871,7 @@ class DGitProvider extends Plugin { const files = await this.getDirectory('/') this.filesToSend = [] for (const file of files) { - const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`) + const c = await window.remixFileSystem.readFile(`${workspace.absolutePath}/${file}`, null) zip.file(file, c) } await zip.generateAsync({ @@ -1064,20 +987,19 @@ class DGitProvider extends Plugin { } async repositories(input: { token: string }) { + console.log(input) const octokit = new Octokit({ auth: input.token }) + + console.log('octokit', input.token) - const data = await octokit.request('GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}', { - sort: "pushed", - direction: "desc", + const data = await octokit.request('GET /user/repos', { per_page: 100, - affiliation: "owner,collaborator" + page: 1 }) - - octokit - + console.log(data.data) return data.data } diff --git a/apps/remix-ide/src/app/tabs/locales/en/git.json b/apps/remix-ide/src/app/tabs/locales/en/git.json new file mode 100644 index 0000000000..2ccdb2e2ba --- /dev/null +++ b/apps/remix-ide/src/app/tabs/locales/en/git.json @@ -0,0 +1,15 @@ +{ + "git.push": "push", + "git.pull": "pull", + "git.commit": "commit", + "git.sync": "sync", + "git.publish": "publish", + "git.ignore": "ignore", + "git.createBranch": "create branch", + "git.deleteBranch": "delete branch", + "git.mergeBranch": "merge branch", + "git.rebaseBranch": "rebase branch", + "git.checkout": "checkout", + "git.fetch": "fetch", + "git.refresh": "refresh" +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/tabs/locales/en/index.js b/apps/remix-ide/src/app/tabs/locales/en/index.js index 8da7dd179f..31c606f7a7 100644 --- a/apps/remix-ide/src/app/tabs/locales/en/index.js +++ b/apps/remix-ide/src/app/tabs/locales/en/index.js @@ -15,6 +15,7 @@ import solUmlGenJson from './solUmlGen.json' import remixAppJson from './remixApp.json' import remixUiTabsJson from './remixUiTabs.json' import circuitJson from './circuit.json'; +import gitJson from './git.json' export default { ...debuggerJson, @@ -33,5 +34,6 @@ export default { ...solUmlGenJson, ...remixAppJson, ...remixUiTabsJson, - ...circuitJson + ...circuitJson, + ...gitJson } diff --git a/apps/remix-ide/src/assets/list.json b/apps/remix-ide/src/assets/list.json index 7c75a856e5..b22d882d4b 100644 --- a/apps/remix-ide/src/assets/list.json +++ b/apps/remix-ide/src/assets/list.json @@ -1079,9 +1079,22 @@ "bzzr://6e70fe6bfe8c3fc63f8a3eba733731aab129e6e58828b78058e53bb50440709b", "dweb:/ipfs/QmZy5ho8W943FMGwppXZFS1WFrVwV3UXhUUwcD7oH5vrYe" ] + }, + { + "path": "soljson-v0.8.24+commit.e11b9ed9.js", + "version": "0.8.24", + "build": "commit.e11b9ed9", + "longVersion": "0.8.24+commit.e11b9ed9", + "keccak256": "0x1b6ceeabad21bbb2011ba13373160f7c4d46c11371a354243ee1be07159345f3", + "sha256": "0x11b054b55273ec55f6ab3f445eb0eb2c83a23fed43d10079d34ac3eabe6ed8b1", + "urls": [ + "bzzr://c604bdd6384bf73594cd0e5cfbe979048191549ebc88e70996346f3b744c0680", + "dweb:/ipfs/QmW2SQbEhiz3n2qV5iL8WBgzapv6cXjkLStvTMpCZhvr2x" + ] } ], "releases": { + "0.8.24": "soljson-v0.8.24+commit.e11b9ed9.js", "0.8.23": "soljson-v0.8.23+commit.f704f362.js", "0.8.22": "soljson-v0.8.22+commit.4fc1097e.js", "0.8.21": "soljson-v0.8.21+commit.d9974bed.js", @@ -1173,5 +1186,5 @@ "0.4.0": "soljson-v0.4.0+commit.acd334c9.js", "0.3.6": "soljson-v0.3.6+commit.3fc68da5.js" }, - "latestRelease": "0.8.23" + "latestRelease": "0.8.24" } \ No newline at end of file diff --git a/libs/remix-ui/git/src/components/gitui.tsx b/libs/remix-ui/git/src/components/gitui.tsx index 32cfe7c321..0c15769cfb 100644 --- a/libs/remix-ui/git/src/components/gitui.tsx +++ b/libs/remix-ui/git/src/components/gitui.tsx @@ -162,13 +162,6 @@ export const GitUI = (props: IGitUi) => { >