diff --git a/apps/remix-ide/src/app/files/dgitProvider.ts b/apps/remix-ide/src/app/files/dgitProvider.ts index dce9e72688..95f2cc19de 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.ts +++ b/apps/remix-ide/src/app/files/dgitProvider.ts @@ -19,7 +19,7 @@ import { Octokit, App } from "octokit" import { OctokitResponse } from '@octokit/types' import { Endpoints } from "@octokit/types" import { IndexedDBStorage } from './filesystems/indexedDB' -import { GitHubUser, RateLimit, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput, userEmails } from '@remix-ui/git' +import { GitHubUser, branch, commitChange, remote, pagedCommits, remoteCommitsInputType, cloneInputType, fetchInputType, pullInputType, pushInputType, currentBranchInput, branchInputType, addInput, rmInput, resolveRefInput, readBlobInput, repositoriesInput, commitInput, branchDifference, compareBranchesInput, initInput, userEmails } from '@remix-ui/git' import { LibraryProfile, StatusEvents } from '@remixproject/plugin-utils' import { ITerminal } from '@remixproject/plugin-api/src/lib/terminal' @@ -252,7 +252,7 @@ class DGitProvider extends Plugin { this.emit('checkout') } - async log(cmd:{ref:string}):Promise { + async log(cmd: { ref: string }): Promise { if ((Registry.getInstance().get('platform').api.isDesktop())) { const status = await this.call('isogit', 'log', { @@ -362,8 +362,7 @@ class DGitProvider extends Plugin { 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({ ...config ? config : await this.addIsomorphicGitConfigFS() })).map((remote) => { return { name: remote.remote, url: remote.url } } ) } catch (e) { // do nothing @@ -573,7 +572,7 @@ class DGitProvider extends Plugin { const result = await this.call('isogit', 'clone', cmd) this.call('fs', 'openWindow', folder) return result - } catch (e){ + } catch (e) { this.call('notification', 'alert', { id: 'dgitAlert', message: 'Unexpected error while cloning the repository: \n' + e.toString(), @@ -710,8 +709,9 @@ class DGitProvider extends Plugin { this.call('terminal', 'log', { type: 'error', value: `Could not checkout submodule to ${result[0]}` - })} else { - this.call('terminal', 'logHtml',`Checked out submodule ${dir} to ${result[0]}`) + }) + } else { + this.call('terminal', 'logHtml', `Checked out submodule ${dir} to ${result[0]}`) } } @@ -1004,37 +1004,29 @@ class DGitProvider extends Plugin { async getGitHubUser(input: { token: string }): Promise<{ user: GitHubUser, - ratelimit: RateLimit, emails: userEmails, scopes: string[] }> { - const octokit = new Octokit({ - auth: input.token - }) - - const ratelimit = await octokit.request('GET /rate_limit', { - headers: { - 'X-GitHub-Api-Version': '2022-11-28' - } - }) - // epoch timestamp to local date time - const localResetTime = ratelimit.data.rate.reset * 1000 - const localResetTimeString = new Date(localResetTime).toLocaleString() - - console.log('rate limit', localResetTimeString) + try { + console.log('getGitHubUser', input) + const octokit = new Octokit({ + auth: input.token + }) - const user = await octokit.request('GET /user') - const emails = await octokit.request('GET /user/emails') + const user = await octokit.request('GET /user') + const emails = await octokit.request('GET /user/emails') - const scopes = user.headers['x-oauth-scopes']; + const scopes = user.headers['x-oauth-scopes']; - console.log('scopes', scopes) + console.log('scopes', scopes) - return { - user: user.data, - emails: emails.data, - ratelimit: ratelimit.data, - scopes: scopes.split(',') + return { + user: user.data, + emails: emails.data, + scopes: scopes.split(',') + } + } catch (e) { + return null } } diff --git a/libs/remix-ui/git/src/components/github/devicecode.tsx b/libs/remix-ui/git/src/components/github/devicecode.tsx index 0fad875936..2fbe51f0ac 100644 --- a/libs/remix-ui/git/src/components/github/devicecode.tsx +++ b/libs/remix-ui/git/src/components/github/devicecode.tsx @@ -83,10 +83,6 @@ export const GetDeviceCode = () => { }, []) - useEffect(() => { - console.log('context.rateLimit', context.rateLimit) - }, [context.rateLimit]) - return ( <> {(context.gitHubUser && context.gitHubUser.login) ? null : diff --git a/libs/remix-ui/git/src/lib/gitactions.ts b/libs/remix-ui/git/src/lib/gitactions.ts index fdb090242e..40e0c3aa1a 100644 --- a/libs/remix-ui/git/src/lib/gitactions.ts +++ b/libs/remix-ui/git/src/lib/gitactions.ts @@ -1,8 +1,8 @@ import { ViewPlugin } from "@remixproject/engine-web"; import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; import React from "react"; -import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRateLimit, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails } from "../state/gitpayload"; -import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types'; +import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails } 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 { removeSlash } from "../utils"; import { disableCallBacks, enableCallBacks } from "./listeners"; import { AlertModal, ModalTypes } from "@remix-ui/app"; @@ -510,11 +510,7 @@ export const remoteCommits = async (url: string, branch: string, length: number) }) } } catch (e) { - console.log(e) - plugin.call('notification', 'alert', { - title: 'Error', - message: e.message - }) + // do nothing } } @@ -557,7 +553,6 @@ export const loadGitHubUserFromToken = async () => { if (token) { const data: { user: GitHubUser, - ratelimit: RateLimit scopes: string[] emails: userEmails } = await plugin.call('dgitApi' as any, 'getGitHubUser', { token }); @@ -572,7 +567,6 @@ export const loadGitHubUserFromToken = async () => { if (data.user && data.user.login && (storedUsername !== data.user.login)) await plugin.call('config', 'setAppParameter', 'settings/github-user-name', data.user.login) dispatch(setGitHubUser(data.user)) - dispatch(setRateLimit(data.ratelimit)) dispatch(setScopes(data.scopes)) dispatch(setUserEmails(data.emails)) diff --git a/libs/remix-ui/git/src/state/gitpayload.ts b/libs/remix-ui/git/src/state/gitpayload.ts index 31ea4d0e03..b7d1723d5c 100644 --- a/libs/remix-ui/git/src/state/gitpayload.ts +++ b/libs/remix-ui/git/src/state/gitpayload.ts @@ -59,12 +59,6 @@ export const setUserEmails = (emails: userEmails) => { } } -export const setRateLimit = (rateLimit: any) => { - return { - type: 'SET_RATE_LIMIT', - payload: rateLimit - } -} export const setScopes = (scopes: string[]) => { return { diff --git a/libs/remix-ui/git/src/state/gitreducer.tsx b/libs/remix-ui/git/src/state/gitreducer.tsx index 3d55d6818c..55d15fd615 100644 --- a/libs/remix-ui/git/src/state/gitreducer.tsx +++ b/libs/remix-ui/git/src/state/gitreducer.tsx @@ -157,13 +157,6 @@ export const gitReducer = (state: gitState = defaultGitState, action: Actions): gitHubUser: action.payload } - case 'SET_RATE_LIMIT': - console.log("rate limit", action.payload) - return { - ...state, - rateLimit: action.payload - } - case 'SET_GITHUB_ACCESS_TOKEN': return { ...state, diff --git a/libs/remix-ui/git/src/types/index.ts b/libs/remix-ui/git/src/types/index.ts index cea92b30f2..14e268cde1 100644 --- a/libs/remix-ui/git/src/types/index.ts +++ b/libs/remix-ui/git/src/types/index.ts @@ -3,7 +3,6 @@ import { IRemixApi } from "@remixproject/plugin-api" import { LibraryProfile, StatusEvents } from "@remixproject/plugin-utils" import { CommitObject, ReadBlobResult, ReadCommitResult, StatusRow } from "isomorphic-git" export type GitHubUser = Partial -export type RateLimit = Endpoints["GET /rate_limit"]["response"]["data"] export type userEmails = Endpoints["GET /user/emails"]["response"]["data"] export interface IGitApi { @@ -179,7 +178,6 @@ export type gitState = { remoteCommitCount: number upstream: remote gitHubUser: GitHubUser - rateLimit: RateLimit userEmails: userEmails gitHubScopes: string[] gitHubAccessToken: string @@ -293,7 +291,6 @@ export const defaultGitState: gitState = { remoteCommitCount: 0, upstream: null, gitHubUser: {} as GitHubUser, - rateLimit: {} as RateLimit, userEmails: [] as userEmails, gitHubScopes: [], gitHubAccessToken: "",