change upstream object

git4refactor
filip mertens 6 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. 2
      libs/remix-ui/git/src/components/buttons/sourcecontrolbuttons.tsx
  4. 6
      libs/remix-ui/git/src/components/panels/commands/fetch.tsx
  5. 21
      libs/remix-ui/git/src/components/panels/commands/pushpull.tsx
  6. 2
      libs/remix-ui/git/src/components/panels/commits.tsx
  7. 34
      libs/remix-ui/git/src/lib/gitactions.ts
  8. 2
      libs/remix-ui/git/src/state/context.tsx
  9. 2
      libs/remix-ui/git/src/state/gitpayload.ts
  10. 4
      libs/remix-ui/git/src/state/gitreducer.tsx
  11. 6
      libs/remix-ui/git/src/types/index.ts

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

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

@ -87,7 +87,7 @@ export const SourceControlButtons = (props: SourceControlButtonsProps) => {
}
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 fetchIsDisabled = () => {
return context.upstream === '' || context.remotes.length === 0
return (!context.upstream) || context.remotes.length === 0
}
return (
<>
<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(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()} 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 w-50 long-and-truncated">Fetch {context.currentBranch.name}</GitUIButton>
</div>
</>)
}

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

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

@ -22,7 +22,7 @@ export interface gitActions {
getGitHubUser(): Promise<any>
diff(commitChange: commitChange): Promise<void>
resolveRef(ref: string): Promise<string>
setUpstreamRemote(upstream: string): Promise<void>
setUpstreamRemote(upstream: remote): Promise<void>
getBranches: () => Promise<void>
getRemotes: () => 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 {
type: 'SET_UPSTREAM',
payload: upstream

@ -1,6 +1,6 @@
import { ReadCommitResult } from "isomorphic-git"
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 {
type: string
@ -105,7 +105,7 @@ export const gitReducer = (state: gitState = defaultGitState, action: Action): g
case 'SET_UPSTREAM':
return {
...state,
upstream: action.payload
upstream: (action as setUpstreamAction).payload
}
case 'SET_COMMIT_CHANGES':

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

Loading…
Cancel
Save