git4refactor
filip mertens 7 months ago
parent 353b5670ad
commit 53eee90070
  1. 7
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 2
      libs/remix-ui/git/src/components/buttons/commitmessage.tsx
  3. 2
      libs/remix-ui/git/src/components/gitui.tsx
  4. 41
      libs/remix-ui/git/src/components/navigation/branchedetails.tsx
  5. 15
      libs/remix-ui/git/src/components/panels/branches.tsx
  6. 8
      libs/remix-ui/git/src/components/panels/branches/branchdifferencedetails.tsx
  7. 6
      libs/remix-ui/git/src/components/panels/branches/localbranchdetails.tsx
  8. 7
      libs/remix-ui/git/src/components/panels/commits.tsx
  9. 5
      libs/remix-ui/git/src/lib/gitactions.ts

@ -300,14 +300,14 @@ class DGitProvider extends Plugin {
}
async getCommitChanges(commitHash1, commitHash2): Promise<commitChange[]> {
console.log(commitHash1, commitHash2, [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })])
//console.log(commitHash1, commitHash2, [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })])
const result: commitChange[] = await git.walk({
...await this.addIsomorphicGitConfigFS(),
trees: [git.TREE({ ref: commitHash1 }), git.TREE({ ref: commitHash2 })],
map: async function (filepath, [A, B]) {
// ignore directories
console.log(filepath, A, B)
//console.log(filepath, A, B)
if (filepath === '.') {
return
@ -330,7 +330,7 @@ class DGitProvider extends Plugin {
path: filepath,
}
console.log('Aoid', Aoid, 'Boid', Boid, commitChange)
//console.log('Aoid', Aoid, 'Boid', Boid, commitChange)
// determine modification type
if (Aoid !== Boid) {
@ -802,6 +802,7 @@ class DGitProvider extends Plugin {
relative: input.relative,
input
}
console.log('fetch input', cmd)
let result
if ((Registry.getInstance().get('platform').api.isDesktop())) {
result = await this.call('isogit', 'fetch', cmd)

@ -76,7 +76,7 @@ export const CommitMessage = () => {
const publishEnabled = () => {
const remoteEquivalentBranch = context.branches.find((b) => b.name === context.currentBranch.name && b.remote)
return remoteEquivalentBranch === undefined
return remoteEquivalentBranch === undefined && getRemote()!== null
}
const publishBranch = async () => {

@ -159,7 +159,7 @@ export const GitUI = (props: IGitUi) => {
<BranchesNavigation eventKey="2" activePanel={activePanel} callback={setActivePanel} />
<Accordion.Collapse className='bg-light' eventKey="2">
<>
<Branches isOpen={activePanel === '2'} /></>
<Branches/></>
</Accordion.Collapse>
<hr></hr>
<RemotesNavigation eventKey="5" activePanel={activePanel} callback={setActivePanel} />

@ -3,6 +3,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import React, { useContext, useEffect } from "react";
import { gitActionsContext } from "../../state/context";
import { branch } from "../../types";
import GitUIButton from "../buttons/gituibutton";
import { gitPluginContext } from "../gitui";
interface BrancheDetailsNavigationProps {
@ -26,14 +27,28 @@ export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) =
}
}
const getRemote = () => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const openRemote = () => {
window.open(`${branch.remote.url}/tree/${branch.name}`, '_blank');
const remote = branch.remote || getRemote()
window.open(`${remote.url}/tree/${branch.name}`, '_blank');
}
const reloadBranch = () => {
actions.getBranchCommits(branch, 1)
}
const canFetch = () => {
if (getRemote())
return context.branches.find((b) => b.name === branch.name && b.remote && b.remote.url === getRemote().url) ? true : false
}
const fetchBranch = async () => {
actions.fetch(null, branch.name, null, null, false, true)
}
return (
<>
<div className="d-flex flex-row w-100 mb-2 mt-2">
@ -46,16 +61,30 @@ export const BrancheDetailsNavigation = (props: BrancheDetailsNavigationProps) =
</div>
{context.currentBranch.name === branch.name ?
<FontAwesomeIcon className='ml-auto mr-1 pointer text-success' icon={faToggleOff} onClick={() => checkout(branch)}></FontAwesomeIcon>
<GitUIButton className="btn btn-sm p-0 mr-1" onClick={() => { }}>
<FontAwesomeIcon className='pointer text-success' icon={faToggleOff} ></FontAwesomeIcon>
</GitUIButton>
:
<FontAwesomeIcon className='ml-auto mr-1 pointer' icon={faToggleOn} onClick={() => checkout(branch)}></FontAwesomeIcon>
<GitUIButton className="btn btn-sm p-0 mr-1" onClick={() => checkout(branch)}>
<FontAwesomeIcon icon={faToggleOn}></FontAwesomeIcon>
</GitUIButton>
}
{!branch.remote && canFetch() && <>
<GitUIButton className="btn btn-sm p-0 mr-1 text-muted" onClick={() => fetchBranch()}><FontAwesomeIcon icon={faSync} ></FontAwesomeIcon></GitUIButton>
<GitUIButton className="btn btn-sm p-0 mr-1 text-muted" onClick={() => openRemote()}><FontAwesomeIcon icon={faGlobe} ></FontAwesomeIcon></GitUIButton>
</>}
{branch.remote?.url && <>
<FontAwesomeIcon className='ml-2 pointer' icon={faSync} onClick={() => reloadBranch()}></FontAwesomeIcon></>}
<GitUIButton className="btn btn-sm p-0 mr-1 text-muted" onClick={() => reloadBranch()}>
<FontAwesomeIcon icon={faSync} ></FontAwesomeIcon>
</GitUIButton>
</>}
{branch.remote?.url && <>
<FontAwesomeIcon className='ml-2 pointer' icon={faGlobe} onClick={() => openRemote()}></FontAwesomeIcon></>}
<GitUIButton className="btn btn-sm p-0 mr-1 text-muted" onClick={() => openRemote()}>
<FontAwesomeIcon icon={faGlobe} ></FontAwesomeIcon>
</GitUIButton>
</>}
</div>
</>
);

@ -7,11 +7,7 @@ import { gitPluginContext } from "../gitui";
import { LocalBranchDetails } from "./branches/localbranchdetails";
import { RemoteBranchDetails } from "./branches/remotebranchedetails";
interface BranchesProps {
isOpen: boolean;
}
export const Branches = ({isOpen}: BranchesProps) => {
export const Branches = () => {
const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext)
const [newBranch, setNewBranch] = useState({ value: "" });
@ -28,15 +24,10 @@ export const Branches = ({isOpen}: BranchesProps) => {
}
};
useEffect(() => {
console.log("open branches", context.branches)
//if(context.branches && context.branches.length) return
//actions.getBranches()
},[isOpen])
useEffect(() => {
console.log("branches", context.branches)
},[context.branches])
}, [context.branches])
return (
@ -66,7 +57,7 @@ export const Branches = ({isOpen}: BranchesProps) => {
className="btn w-md-25 w-100 btn-primary"
id="createbranch-btn"
>
create new branch
create new branch
</GitUIButton>
</div> : <div className="text-muted">No branches</div>}
</div>

@ -5,6 +5,7 @@ import { CommitDetails } from "../commits/commitdetails";
import { CommitsNavigation } from "../../navigation/commits";
import { branch, remote } from "../../../types";
import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui";
export interface BrancheDifferenceProps {
commits: ReadCommitResult[];
@ -18,12 +19,17 @@ export interface BrancheDifferenceProps {
export const BranchDifferenceDetails = (props: BrancheDifferenceProps) => {
const { commits, title, branch, remote, ahead, behind } = props;
const [activePanel, setActivePanel] = useState<string>("");
const context = React.useContext(gitPluginContext)
const actions = React.useContext(gitActionsContext)
if (commits.length === 0) return null
const getRemote = () => {
return remote ? remote : context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const getCommitChanges = async (commit: ReadCommitResult) => {
await actions.getCommitChanges(commit.oid, commit.commit.parent[0])
await actions.getCommitChanges(commit.oid, commit.commit.parent[0], null, getRemote())
}
return (

@ -54,8 +54,12 @@ export const LocalBranchDetails = (props: BrancheDetailsProps) => {
}
};
const getRemote = () => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const getCommitChanges = async (commit: ReadCommitResult) => {
await actions.getCommitChanges(commit.oid, commit.commit.parent[0])
await actions.getCommitChanges(commit.oid, commit.commit.parent[0], null, getRemote())
}
return (<Accordion activeKey={activePanel} defaultActiveKey="">

@ -29,8 +29,13 @@ export const Commits = () => {
//actions.getBranchCommits(branch, lastPageNumber+1)
}
const getRemote = () => {
return context.upstream ? context.upstream : context.defaultRemote ? context.defaultRemote : null
}
const getCommitChanges = async (commit: ReadCommitResult) => {
await actions.getCommitChanges(commit.oid, commit.commit.parent[0])
await actions.getCommitChanges(commit.oid, commit.commit.parent[0],null, getRemote())
}
const fetchIsDisabled = () => {

@ -710,11 +710,14 @@ export const getCommitChanges = async (oid1: string, oid2: string, branch?: bran
log = await plugin.call('dGitProvider', 'log', {
ref: branch ? branch.name : 'HEAD',
})
console.log(log, 'log')
} catch (e) {
console.log(e, 'log error')
}
if (log) {
const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2)
if (!foundCommit) {
if (!foundCommit && remote) {
console.log('getCommitChanges fetching remote')
await fetch(remote ? remote.remote : null, branch ? branch.name : null, null, 5, true, true)
}
}

Loading…
Cancel
Save