change upstream object

git4refactor
filip mertens 7 months ago
parent 5b3df39c37
commit e1c1d94336
  1. 2
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 2
      apps/remix-ide/src/app/files/fileManager.ts
  3. 34
      apps/remix-ide/src/app/plugins/git.tsx
  4. 2
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  5. 6
      libs/remix-ui/git/src/components/panels/commands/fetch.tsx
  6. 21
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  7. 2
      libs/remix-ui/git/src/components/panels/commits.tsx
  8. 40
      libs/remix-ui/git/src/lib/gitactions.ts
  9. 2
      libs/remix-ui/git/src/state/context.tsx
  10. 2
      libs/remix-ui/git/src/state/gitpayload.ts
  11. 4
      libs/remix-ui/git/src/state/gitreducer.tsx
  12. 6
      libs/remix-ui/git/src/types/index.ts

@ -1105,7 +1105,7 @@ class DGitProvider extends Plugin {
const accessToken = input.token; const accessToken = input.token;
let page = input.page || 1 const page = input.page || 1
const perPage = input.per_page || 10 const perPage = input.per_page || 10
const baseURL = 'https://api.github.com/user/repos' const baseURL = 'https://api.github.com/user/repos'

@ -723,7 +723,7 @@ class FileManager extends Plugin {
async closeDiff(change: commitChange) { async closeDiff(change: commitChange) {
if(!change.readonly){ if(!change.readonly){
let file = this.normalize(change.path) const file = this.normalize(change.path)
delete this.openedFiles[file] delete this.openedFiles[file]
if (!Object.keys(this.openedFiles).length) { if (!Object.keys(this.openedFiles).length) {
this._deps.config.set('currentFile', '') this._deps.config.set('currentFile', '')

@ -4,30 +4,30 @@ import React from 'react' // eslint-disable-line
import { gitState, GitUI } from '@remix-ui/git'; import { gitState, GitUI } from '@remix-ui/git';
const profile = { const profile = {
name: 'dgit', name: 'dgit',
desciption: 'Git plugin for Remix', desciption: 'Git plugin for Remix',
methods: ['pull', 'track', 'diff', 'clone', 'open'], methods: ['pull', 'track', 'diff', 'clone', 'open'],
events: [''], events: [''],
version: '0.0.1', version: '0.0.1',
location: 'sidePanel', location: 'sidePan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uNTEyMyA4LjIyMTY4QzE5LjUxMjMgOC44MTYzMiAxOS4yNzYgOS4zODY2IDE4Ljg1NTYgOS44MDcwNkMxOC40MzUxIDEwLjIyNzUgMTcuODY0OCAxMC40NjM4IDE3LjI3MDIgMTAuNDYzOFoiIGZpbGw9IiM0MjQyNDIiLz4KPC9zdmc+Cg=="
} }
export class GitPlugin extends ViewPlugin { export class GitPlugin extends ViewPlugin {
constructor() { constructor() {
super(profile) super(profile)
} }
onDeactivation(): void { onDeactivation(): void {
this.call('fileDecorator', 'clearFileDecorators') this.call('fileDecorator', 'clearFileDecorators')
this.call('manager', 'activatePlugin', 'dGitProvider') this.call('manager', 'activatePlugin', 'dGitProvider')
} }
render() { render() {
return <div id='gitTab'><GitUI plugin={this} /></div> return <div id='gitTab'><GitUI plugin={this} /></div>
} }
} }

@ -87,7 +87,7 @@ export const SourceControlButtons = (props: SourceControlButtonsProps) => {
} }
const buttonsDisabled = () => { const buttonsDisabled = () => {
return context.upstream === '' || context.remotes.length === 0 return (!context.upstream) || context.remotes.length === 0
} }

@ -9,13 +9,13 @@ export const Fetch = () => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
const fetchIsDisabled = () => { const fetchIsDisabled = () => {
return context.upstream === '' || context.remotes.length === 0 return (!context.upstream) || context.remotes.length === 0
} }
return ( return (
<> <>
<div className="btn-group w-100" role="group"> <div className="btn-group w-100" role="group">
<GitUIButton disabledCondition={fetchIsDisabled()} type="button" onClick={async () => actions.fetch()} className="btn btn-primary mr-1">Fetch {context.upstream}</GitUIButton> <GitUIButton disabledCondition={fetchIsDisabled()} type="button" onClick={async () => actions.fetch()} className="btn btn-primary mr-1 w-50"><>Fetch {context.upstream}</></GitUIButton>
<GitUIButton disabledCondition={fetchIsDisabled()} type="button" onClick={async () => actions.fetch(null, null, context.currentBranch.name, null, true )} className="btn btn-primary">Fetch {context.currentBranch.name}</GitUIButton> <GitUIButton disabledCondition={fetchIsDisabled()} type="button" onClick={async () => actions.fetch(null, null, context.currentBranch.name, null, true )} className="btn btn-primary w-50 long-and-truncated">Fetch {context.currentBranch.name}</GitUIButton>
</div> </div>
</>) </>)
} }

@ -2,9 +2,9 @@ import React, { useEffect, useState } from "react";
import { gitActionsContext } from "../../../state/context"; import { gitActionsContext } from "../../../state/context";
import { gitPluginContext } from "../../gitui"; import { gitPluginContext } from "../../gitui";
import { selectStyles, selectTheme } from "../../../types/styles"; import { selectStyles, selectTheme } from "../../../types/styles";
import Select, { Options, OptionsOrGroups } from 'react-select' import Select from 'react-select'
import { setUpstream } from "../../../state/gitpayload";
import GitUIButton from "../../buttons/gituibutton"; import GitUIButton from "../../buttons/gituibutton";
import { remote } from "../../../types";
export const PushPull = () => { export const PushPull = () => {
const context = React.useContext(gitPluginContext) const context = React.useContext(gitPluginContext)
@ -19,8 +19,8 @@ export const PushPull = () => {
useEffect(() => { useEffect(() => {
setRemoteBranch(context.currentBranch.name) setRemoteBranch(context.currentBranch.name)
setLocalBranch(context.currentBranch.name) setLocalBranch(context.currentBranch.name)
if ((!context.upstream || context.upstream === '') && context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.remote) { if ((!context.upstream) && context.currentBranch && context.currentBranch.remote && context.currentBranch.remote.remote) {
actions.setUpstreamRemote(context.currentBranch.remote.remote) actions.setUpstreamRemote(context.currentBranch.remote)
} }
}, [context.currentBranch]) }, [context.currentBranch])
@ -35,9 +35,12 @@ export const PushPull = () => {
setLocalBranch(value) setLocalBranch(value)
} }
const onRemoteChange = (value: any) => { const onRemoteChange = (value: string) => {
console.log('onRemoteChange', value, context) console.log('onRemoteChange', value, context)
actions.setUpstreamRemote(value) const remote: remote = context.remotes.find(r => r.remote === value)
if(remote) {
actions.setUpstreamRemote(remote)
}
} }
useEffect(() => { useEffect(() => {
@ -52,11 +55,11 @@ export const PushPull = () => {
const push = async () => { const push = async () => {
console.log('PUSH', context.upstream, localBranch, remoteBranch, force) console.log('PUSH', context.upstream, localBranch, remoteBranch, force)
actions.push(context.upstream, localBranch, remoteBranch, force) actions.push(context.upstream.remote, localBranch, remoteBranch, force)
} }
const pull = async () => { const pull = async () => {
actions.pull(context.upstream, localBranch, remoteBranch) actions.pull(context.upstream.remote, localBranch, remoteBranch)
} }
@ -94,7 +97,7 @@ export const PushPull = () => {
const pushPullIsDisabled = () => { const pushPullIsDisabled = () => {
return localBranch === '' || remoteBranch === '' || context.upstream === '' || context.remotes.length === 0 return localBranch === '' || remoteBranch === '' || !context.upstream || context.remotes.length === 0
} }

@ -35,7 +35,7 @@ export const Commits = () => {
} }
const fetchIsDisabled = () => { const fetchIsDisabled = () => {
return context.upstream === '' || context.remotes.length === 0 return (!context.upstream)|| context.remotes.length === 0
} }
return ( return (

@ -93,7 +93,7 @@ export const getRemotes = async () => {
dispatch(setRemotes(remotes)); dispatch(setRemotes(remotes));
} }
export const setUpstreamRemote = async (remote: string) => { export const setUpstreamRemote = async (remote: remote) => {
dispatch(setUpstream(remote)); dispatch(setUpstream(remote));
} }
@ -842,6 +842,24 @@ export const fetchBranch = async (branch: branch, page: number) => {
//dispatch(setRemoteBranchCommits({ branch, commits: mergeCommits })) //dispatch(setRemoteBranchCommits({ branch, commits: mergeCommits }))
} }
export const getBranchDifferences = async (branch: branch, remote: remote) => {
try {
const branchDifference: branchDifference = await plugin.call('dGitProvider', 'compareBranches', {
branch,
remote
})
dispatch(setBranchDifferences(
{
branch,
remote,
branchDifference: branchDifference
}))
} catch (e) {
}
}
export const getBranchCommits = async (branch: branch, page: number) => { export const getBranchCommits = async (branch: branch, page: number) => {
dispatch(setLoading(true)) dispatch(setLoading(true))
await disableCallBacks() await disableCallBacks()
@ -851,25 +869,7 @@ export const getBranchCommits = async (branch: branch, page: number) => {
const commits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', { const commits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', {
ref: branch.name, ref: branch.name,
}) })
try { console.log(commits)
const branchDifference: branchDifference = await plugin.call('dGitProvider', 'compareBranches', {
branch,
remote: {
remote: 'origin',
url: ''
}
})
console.log(commits, branchDifference)
dispatch(setBranchDifferences(
{
branch,
remote:
{ remote: 'origin', url: '' },
branchDifference: branchDifference
}))
} catch (e) {
}
dispatch(setLocalBranchCommits({ branch, commits })) dispatch(setLocalBranchCommits({ branch, commits }))
} else { } else {
await fetchBranch(branch, page) await fetchBranch(branch, page)

@ -22,7 +22,7 @@ export interface gitActions {
getGitHubUser(): Promise<any> getGitHubUser(): Promise<any>
diff(commitChange: commitChange): Promise<void> diff(commitChange: commitChange): Promise<void>
resolveRef(ref: string): Promise<string> resolveRef(ref: string): Promise<string>
setUpstreamRemote(upstream: string): Promise<void> setUpstreamRemote(upstream: remote): Promise<void>
getBranches: () => Promise<void> getBranches: () => Promise<void>
getRemotes: () => Promise<void> getRemotes: () => Promise<void>
setDefaultRemote: (remote: remote) => Promise<void> setDefaultRemote: (remote: remote) => Promise<void>

@ -115,7 +115,7 @@ export const setRemotes = (remotes: remote[]) => {
} }
} }
export const setUpstream = (upstream: string) => { export const setUpstream = (upstream: remote) => {
return { return {
type: 'SET_UPSTREAM', type: 'SET_UPSTREAM',
payload: upstream payload: upstream

@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git" import { ReadCommitResult } from "isomorphic-git"
import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers" import { allChangedButNotStagedFiles, getFilesByStatus, getFilesWithNotModifiedStatus } from "../lib/fileHelpers"
import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction } from "../types" import { branch, commitChange, defaultGitState, fileStatusResult, gitState, setRemoteBranchCommitsAction, setLocalBranchCommitsAction, setBranchDifferencesAction, setDefaultRemoteAction, setRemotesAction, setUpstreamAction } from "../types"
interface Action { interface Action {
type: string type: string
@ -105,7 +105,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
case 'SET_UPSTREAM': case 'SET_UPSTREAM':
return { return {
...state, ...state,
upstream: action.payload upstream: (action as setUpstreamAction).payload
} }
case 'SET_COMMIT_CHANGES': case 'SET_COMMIT_CHANGES':

@ -30,7 +30,7 @@ export type gitState = {
syncStatus: syncStatus, syncStatus: syncStatus,
localCommitCount: number localCommitCount: number
remoteCommitCount: number remoteCommitCount: number
upstream: string upstream: remote
gitHubUser: GitHubUser gitHubUser: GitHubUser
rateLimit: RateLimit rateLimit: RateLimit
gitHubScopes: string[] gitHubScopes: string[]
@ -143,7 +143,7 @@ export const defaultGitState: gitState = {
syncStatus: syncStatus.none, syncStatus: syncStatus.none,
localCommitCount: 0, localCommitCount: 0,
remoteCommitCount: 0, remoteCommitCount: 0,
upstream: "", upstream: null,
gitHubUser: {} as GitHubUser, gitHubUser: {} as GitHubUser,
rateLimit: {} as RateLimit, rateLimit: {} as RateLimit,
gitHubScopes: [], gitHubScopes: [],
@ -231,7 +231,7 @@ export interface setRemotesAction {
export interface setUpstreamAction { export interface setUpstreamAction {
type: string, type: string,
payload: string payload: remote
} }
export interface setRemoteBranchCommitsAction { export interface setRemoteBranchCommitsAction {

Loading…
Cancel
Save