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 auth: input.token
}) })
const response = await octokit.request('GET /repos/{owner}/{repo}/commits', {
const data = await octokit.request('GET /repos/{owner}/{repo}/commits', {
owner: input.owner, owner: input.owner,
repo: input.repo, repo: input.repo,
sha: input.branch, 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 }) { async repositories(input: { token: string }) {

@ -1,6 +1,5 @@
import React from 'react'; import React, { useEffect } from 'react';
import { useQuery } from '@apollo/client'; import { gql, useQuery } from '@apollo/client';
import { gql } from './../../../types';
const GET_COMMITS = gql(/* GraphQL */` const GET_COMMITS = gql(/* GraphQL */`
query GetCommits($name: String!, $owner: String!, $cursor: String, $limit: Int = 10) { query GetCommits($name: String!, $owner: String!, $cursor: String, $limit: Int = 10) {
@ -17,10 +16,23 @@ const GET_COMMITS = gql(/* GraphQL */`
node { node {
oid oid
messageHeadline messageHeadline
message
committedDate
author { author {
name name
email
date date
} }
parents(first: 1) {
edges {
node {
oid
}
}
}
tree {
oid
}
} }
} }
} }
@ -75,11 +87,14 @@ export const BranchCommits = ({ owner, name }) => {
return ( return (
<div> <div>
<ul> <ul>
{edges.map(({ node }) => ( {edges.map(({ node }) => {
console.log(node)
return(
<li key={node.oid}> <li key={node.oid}>
<p>{node.messageHeadline} - {node.author.name} ({new Date(node.author.date).toLocaleDateString()})</p> <p>{node.messageHeadline} - {node.author.name} ({new Date(node.author.date).toLocaleDateString()})</p>
</li> </li>
))} )
})}
</ul> </ul>
{pageInfo.hasNextPage && ( {pageInfo.hasNextPage && (
<button <button

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

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

@ -18,6 +18,7 @@ export const CommitDetails = (props: CommitDetailsProps) => {
const [activePanel, setActivePanel] = useState<string>(""); const [activePanel, setActivePanel] = useState<string>("");
useEffect(() => { useEffect(() => {
console.log(commit)
if (activePanel === "0") { if (activePanel === "0") {
console.log(commit.oid, commit.commit.parent) console.log(commit.oid, commit.commit.parent)
actions.getCommitChanges(commit.oid, commit.commit.parent[0]) 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) => { 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', { const r = await plugin.call('dGitProvider', 'fetch', {
ref: branch.name, ref: branch.name,
remoteRef: branch.name, remoteRef: branch.name,
@ -704,6 +709,8 @@ export const fetchBranch = async (branch: branch) => {
remote: branch.remote.remote, remote: branch.remote.remote,
depth: 10 depth: 10
}) })
console.log(branch)
const remoteCommits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', { const remoteCommits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', {
ref: r.fetchHead ref: r.fetchHead
}) })

Loading…
Cancel
Save