|
|
@ -1,18 +1,12 @@ |
|
|
|
import { ViewPlugin } from "@remixproject/engine-web"; |
|
|
|
|
|
|
|
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; |
|
|
|
import { ReadBlobResult, ReadCommitResult } from "isomorphic-git"; |
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails } from "../state/gitpayload"; |
|
|
|
import { fileStatus, fileStatusMerge, setRemoteBranchCommits, resetRemoteBranchCommits, setBranches, setCanCommit, setCommitChanges, setCommits, setCurrentBranch, setGitHubUser, setLoading, setRemoteBranches, setRemotes, setRepos, setUpstream, setLocalBranchCommits, setBranchDifferences, setRemoteAsDefault, setScopes, setLog, clearLog, setUserEmails } from "../state/gitpayload"; |
|
|
|
import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types'; |
|
|
|
import { GitHubUser, branch, commitChange, gitActionDispatch, statusMatrixType, gitState, branchDifference, remote, gitLog, fileStatusResult, customGitApi, IGitApi, cloneInputType, fetchInputType, pullInputType, pushInputType, checkoutInput, rmInput, addInput, repository, userEmails } from '../types'; |
|
|
|
import { removeSlash } from "../utils"; |
|
|
|
import { removeSlash } from "../utils"; |
|
|
|
import { disableCallBacks, enableCallBacks } from "./listeners"; |
|
|
|
import { disableCallBacks, enableCallBacks } from "./listeners"; |
|
|
|
import { AlertModal, ModalTypes } from "@remix-ui/app"; |
|
|
|
import { ModalTypes } from "@remix-ui/app"; |
|
|
|
import { gitActions, gitActionsContext } from "../state/context"; |
|
|
|
|
|
|
|
import { gitPluginContext } from "../components/gitui"; |
|
|
|
|
|
|
|
import { setFileDecorators } from "./pluginActions"; |
|
|
|
import { setFileDecorators } from "./pluginActions"; |
|
|
|
import { IDgitSystem, IRemixApi, RemixApi } from "@remixproject/plugin-api"; |
|
|
|
|
|
|
|
import { Plugin } from "@remixproject/engine"; |
|
|
|
import { Plugin } from "@remixproject/engine"; |
|
|
|
import { AnyMxRecord } from "dns"; |
|
|
|
|
|
|
|
import { StatusEvents } from "@remixproject/plugin-utils"; |
|
|
|
|
|
|
|
import { CustomRemixApi } from "@remix-api"; |
|
|
|
import { CustomRemixApi } from "@remix-api"; |
|
|
|
|
|
|
|
|
|
|
|
export const fileStatuses = [ |
|
|
|
export const fileStatuses = [ |
|
|
@ -73,12 +67,10 @@ export const getFileStatusMatrix = async (filepaths: string[]) => { |
|
|
|
fileStatusResult.map((m) => { |
|
|
|
fileStatusResult.map((m) => { |
|
|
|
statusmatrix.map((sm) => { |
|
|
|
statusmatrix.map((sm) => { |
|
|
|
if (JSON.stringify(sm.status) === JSON.stringify(m.status)) { |
|
|
|
if (JSON.stringify(sm.status) === JSON.stringify(m.status)) { |
|
|
|
//Utils.log(m, sm);
|
|
|
|
|
|
|
|
m.statusNames = sm.matrix; |
|
|
|
m.statusNames = sm.matrix; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
//console.log(fileStatusResult);
|
|
|
|
|
|
|
|
if (!filepaths) { |
|
|
|
if (!filepaths) { |
|
|
|
dispatch(fileStatus(fileStatusResult)) |
|
|
|
dispatch(fileStatus(fileStatusResult)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -95,7 +87,7 @@ export const getCommits = async () => { |
|
|
|
"log", |
|
|
|
"log", |
|
|
|
{ ref: "HEAD" } |
|
|
|
{ ref: "HEAD" } |
|
|
|
); |
|
|
|
); |
|
|
|
console.log('commits :>>', commits) |
|
|
|
|
|
|
|
return commits; |
|
|
|
return commits; |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
return []; |
|
|
|
return []; |
|
|
@ -198,7 +190,6 @@ export const commit = async (message: string = "") => { |
|
|
|
|
|
|
|
|
|
|
|
export const addall = async (files: fileStatusResult[]) => { |
|
|
|
export const addall = async (files: fileStatusResult[]) => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
console.log('addall', files.map(f => removeSlash(f.filename))) |
|
|
|
|
|
|
|
const filesToAdd = files.map(f => removeSlash(f.filename)) |
|
|
|
const filesToAdd = files.map(f => removeSlash(f.filename)) |
|
|
|
try { |
|
|
|
try { |
|
|
|
add({ filepath: filesToAdd }) |
|
|
|
add({ filepath: filesToAdd }) |
|
|
@ -379,7 +370,6 @@ const parseError = async (e: any) => { |
|
|
|
cancelLabel: 'Close', |
|
|
|
cancelLabel: 'Close', |
|
|
|
type: ModalTypes.confirm |
|
|
|
type: ModalTypes.confirm |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(result) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// if message contains 404 Not Found, show repo not found
|
|
|
|
// if message contains 404 Not Found, show repo not found
|
|
|
|
else if (e.message.includes('404')) { |
|
|
|
else if (e.message.includes('404')) { |
|
|
@ -648,8 +638,6 @@ export const diff = async (commitChange: commitChange) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => { |
|
|
|
export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => { |
|
|
|
console.log(oid1, oid2, branch, remote) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
let log |
|
|
|
let log |
|
|
|
try { |
|
|
|
try { |
|
|
@ -700,13 +688,11 @@ async function getRepoDetails(url: string) { |
|
|
|
export const fetchBranch = async (branch: branch, page: number) => { |
|
|
|
export const fetchBranch = async (branch: branch, page: number) => { |
|
|
|
if (!branch.remote || !branch.remote.url) return |
|
|
|
if (!branch.remote || !branch.remote.url) return |
|
|
|
const token = await tokenWarning(); |
|
|
|
const token = await tokenWarning(); |
|
|
|
console.log('fetch', branch) |
|
|
|
|
|
|
|
if (page == 1) { |
|
|
|
if (page == 1) { |
|
|
|
dispatch(resetRemoteBranchCommits({ branch })) |
|
|
|
dispatch(resetRemoteBranchCommits({ branch })) |
|
|
|
} |
|
|
|
} |
|
|
|
const { owner, repo } = await getRepoDetails(branch.remote.url); |
|
|
|
const { owner, repo } = await getRepoDetails(branch.remote.url); |
|
|
|
const rc = await plugin.call('dgitApi', 'remotecommits', { token, owner: owner, repo: repo, branch: branch.name, length, page }); |
|
|
|
const rc = await plugin.call('dgitApi', 'remotecommits', { token, owner: owner, repo: repo, branch: branch.name, length, page }); |
|
|
|
console.log(rc, 'remote commits from octokit') |
|
|
|
|
|
|
|
dispatch(setRemoteBranchCommits({ branch, commits: rc })) |
|
|
|
dispatch(setRemoteBranchCommits({ branch, commits: rc })) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
@ -724,7 +710,7 @@ export const getBranchDifferences = async (branch: branch, remote: remote, state |
|
|
|
} |
|
|
|
} |
|
|
|
if (!remote) return |
|
|
|
if (!remote) return |
|
|
|
try { |
|
|
|
try { |
|
|
|
console.log('compare', branch, remote) |
|
|
|
|
|
|
|
const branchDifference: branchDifference = await plugin.call('dgitApi', 'compareBranches', { |
|
|
|
const branchDifference: branchDifference = await plugin.call('dgitApi', 'compareBranches', { |
|
|
|
branch, |
|
|
|
branch, |
|
|
|
remote |
|
|
|
remote |
|
|
@ -737,7 +723,7 @@ export const getBranchDifferences = async (branch: branch, remote: remote, state |
|
|
|
branchDifference: branchDifference |
|
|
|
branchDifference: branchDifference |
|
|
|
})) |
|
|
|
})) |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e) |
|
|
|
// do nothing
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -745,12 +731,10 @@ export const getBranchCommits = async (branch: branch, page: number) => { |
|
|
|
dispatch(setLoading(true)) |
|
|
|
dispatch(setLoading(true)) |
|
|
|
await disableCallBacks() |
|
|
|
await disableCallBacks() |
|
|
|
try { |
|
|
|
try { |
|
|
|
console.log(branch) |
|
|
|
|
|
|
|
if (!branch.remote) { |
|
|
|
if (!branch.remote) { |
|
|
|
const commits: ReadCommitResult[] = await plugin.call('dgitApi', 'log', { |
|
|
|
const commits: ReadCommitResult[] = await plugin.call('dgitApi', 'log', { |
|
|
|
ref: branch.name, |
|
|
|
ref: branch.name, |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(commits) |
|
|
|
|
|
|
|
dispatch(setLocalBranchCommits({ branch, commits })) |
|
|
|
dispatch(setLocalBranchCommits({ branch, commits })) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
await fetchBranch(branch, page) |
|
|
|
await fetchBranch(branch, page) |
|
|
|