git4refactor
filip mertens 9 months ago
parent f4380cece5
commit affc3e6ce8
  1. 45
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 25
      libs/remix-ui/git/src/components/panels/branches/branchCommits.tsx
  3. 8
      libs/remix-ui/git/src/components/panels/branches/branchedetails.tsx
  4. 2
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  5. 1
      libs/remix-ui/git/src/components/panels/commits/commitdetails.tsx
  6. 7
      libs/remix-ui/git/src/lib/gitactions.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 }) {

@ -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 (
<div>
<ul>
{edges.map(({ node }) => (
{edges.map(({ node }) => {
console.log(node)
return(
<li key={node.oid}>
<p>{node.messageHeadline} - {node.author.name} ({new Date(node.author.date).toLocaleDateString()})</p>
</li>
))}
)
})}
</ul>
{pageInfo.hasNextPage && (
<button

@ -23,7 +23,7 @@ export const BranchDetails = (props: BrancheDetailsProps) => {
useEffect(() => {
if (activePanel === "0") {
console.log('GET BRANCH COMMITS', branch)
//actions.getBranchCommits(branch)
actions.getBranchCommits(branch)
}
}, [activePanel])
@ -48,14 +48,14 @@ export const BranchDetails = (props: BrancheDetailsProps) => {
<BrancheDetailsNavigation checkout={checkout} branch={branch} eventKey="0" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className="pl-2 border-left ml-1" eventKey="0">
<div className="ml-1">
{/* {context.branchCommits && Object.entries(context.branchCommits).map(([key, value]) => {
{context.branchCommits && Object.entries(context.branchCommits).map(([key, value]) => {
if(key == branch.name){
return value.map((commit, index) => {
return(<CommitDetails key={index} checkout={checkoutCommit} commit={commit}></CommitDetails>)
})
}
})} */}
<BranchCommits owner={'ethereum'} name={'remix-project'}/>
})}
</div>
</Accordion.Collapse>

@ -59,7 +59,7 @@ export const PushPull = () => {
useEffect(() => {
console.log('context', context.repositories)
console.log('context repositories', context.repositories)
// map context.repositories to options
const localBranches = context.branches && context.branches.length > 0 && context.branches
.filter(branch => !branch.remote)

@ -18,6 +18,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
const [activePanel, setActivePanel] = useState<string>("");
useEffect(() => {
console.log(commit)
if (activePanel === "0") {
console.log(commit.oid, commit.commit.parent)
actions.getCommitChanges(commit.oid, commit.commit.parent[0])

@ -697,6 +697,11 @@ export const getCommitChanges = async (oid1: string, oid2: string) => {
}
export const fetchBranch = async (branch: branch) => {
const token = await tokenWarning();
const rc = await plugin.call('dGitProvider' as any, 'remotecommits', { token, owner:'bunsenstraat', repo:'empty', branch:'main', length });
console.log(rc, 'remote commits from octokit')
dispatch(setBranchCommits({ branch, commits: rc }))
return
const r = await plugin.call('dGitProvider', 'fetch', {
ref: branch.name,
remoteRef: branch.name,
@ -704,6 +709,8 @@ export const fetchBranch = async (branch: branch) => {
remote: branch.remote.remote,
depth: 10
})
console.log(branch)
const remoteCommits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', {
ref: r.fetchHead
})

Loading…
Cancel
Save