diff --git a/apps/remix-ide/src/app/files/dgitProvider.ts b/apps/remix-ide/src/app/files/dgitProvider.ts index 2fb0182f80..e44d1c9a15 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.ts +++ b/apps/remix-ide/src/app/files/dgitProvider.ts @@ -1004,17 +1004,52 @@ class DGitProvider extends Plugin { auth: input.token }) - - - const data = await octokit.request('GET /repos/{owner}/{repo}/commits', { + const response = await octokit.request('GET /repos/{owner}/{repo}/commits', { owner: input.owner, repo: input.repo, sha: input.branch, - per_page: 100 + per_page: 10 }) + const readCommitResults = [] + for (const githubApiCommit of response.data) { + const readCommitResult = { + oid: githubApiCommit.sha, + commit: { + author: { + name: githubApiCommit.commit.author.name, + email: githubApiCommit.commit.author.email, + timestamp: new Date(githubApiCommit.commit.author.date).getTime() / 1000, + timezoneOffset: new Date(githubApiCommit.commit.author.date).getTimezoneOffset() + }, + committer: { + name: githubApiCommit.commit.committer.name, + email: githubApiCommit.commit.committer.email, + timestamp: new Date(githubApiCommit.commit.committer.date).getTime() / 1000, + timezoneOffset: new Date(githubApiCommit.commit.committer.date).getTimezoneOffset() + }, + message: githubApiCommit.commit.message, + tree: githubApiCommit.commit.tree.sha, + parent: githubApiCommit.parents.map(parent => parent.sha) + }, + payload: '' // You may need to reconstruct the commit object in Git's format if necessary + } + readCommitResults.push(readCommitResult) + } + console.log(readCommitResults) - return data.data + // Check for the Link header to determine pagination + const linkHeader = response.headers.link; + + let hasNextPage = false; + if (linkHeader) { + // A simple check for the presence of a 'next' relation in the Link header + hasNextPage = linkHeader.includes('rel="next"'); + } + + console.log("Has next page:", hasNextPage); + + return readCommitResults } async repositories(input: { token: string }) { diff --git a/libs/remix-ui/git/src/components/panels/branches/branchCommits.tsx b/libs/remix-ui/git/src/components/panels/branches/branchCommits.tsx index cd85f8f542..e30db28c2c 100644 --- a/libs/remix-ui/git/src/components/panels/branches/branchCommits.tsx +++ b/libs/remix-ui/git/src/components/panels/branches/branchCommits.tsx @@ -1,6 +1,5 @@ -import React from 'react'; -import { useQuery } from '@apollo/client'; -import { gql } from './../../../types'; +import React, { useEffect } from 'react'; +import { gql, useQuery } from '@apollo/client'; const GET_COMMITS = gql(/* GraphQL */` query GetCommits($name: String!, $owner: String!, $cursor: String, $limit: Int = 10) { @@ -17,10 +16,23 @@ const GET_COMMITS = gql(/* GraphQL */` node { oid messageHeadline + message + committedDate author { name + email date } + parents(first: 1) { + edges { + node { + oid + } + } + } + tree { + oid + } } } } @@ -75,11 +87,14 @@ export const BranchCommits = ({ owner, name }) => { return (
{node.messageHeadline} - {node.author.name} ({new Date(node.author.date).toLocaleDateString()})