|
|
@ -6,7 +6,7 @@ import { GitHubUser, RateLimit, branch, commitChange, gitActionDispatch, statusM |
|
|
|
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 { AlertModal, ModalTypes } from "@remix-ui/app"; |
|
|
|
import { gitActionsContext } from "../state/context"; |
|
|
|
import { gitActions, gitActionsContext } from "../state/context"; |
|
|
|
import { gitPluginContext } from "../components/gitui"; |
|
|
|
import { gitPluginContext } from "../components/gitui"; |
|
|
|
import { setFileDecorators } from "./pluginActions"; |
|
|
|
import { setFileDecorators } from "./pluginActions"; |
|
|
|
import { IDgitSystem, IRemixApi, RemixApi } from "@remixproject/plugin-api"; |
|
|
|
import { IDgitSystem, IRemixApi, RemixApi } from "@remixproject/plugin-api"; |
|
|
@ -694,52 +694,6 @@ export const diff = async (commitChange: commitChange) => { |
|
|
|
commitChange.original = ""; |
|
|
|
commitChange.original = ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
const fullfilename = args; // $(args[0].currentTarget).data('file')
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
const commitOid = await client.call( |
|
|
|
|
|
|
|
"dGitProvider", |
|
|
|
|
|
|
|
"resolveref", |
|
|
|
|
|
|
|
{ ref: "HEAD" } |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { blob } = await client.call("dGitProvider", "readblob", { |
|
|
|
|
|
|
|
oid: commitOid, |
|
|
|
|
|
|
|
filepath: removeSlash(fullfilename), |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const newcontent = await client.call( |
|
|
|
|
|
|
|
"fileManager", |
|
|
|
|
|
|
|
"readFile",//
|
|
|
|
|
|
|
|
removeSlash(fullfilename) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Utils.log(original);
|
|
|
|
|
|
|
|
//Utils.log(newcontent);
|
|
|
|
|
|
|
|
//const filediff = createPatch(filename, original, newcontent); // diffLines(original,newcontent)
|
|
|
|
|
|
|
|
////Utils.log(filediff)
|
|
|
|
|
|
|
|
const filediff: diffObject = { |
|
|
|
|
|
|
|
originalFileName: fullfilename, |
|
|
|
|
|
|
|
updatedFileName: fullfilename, |
|
|
|
|
|
|
|
current: newcontent, |
|
|
|
|
|
|
|
past: original, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return filediff; |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const filediff: diffObject = { |
|
|
|
|
|
|
|
originalFileName: "", |
|
|
|
|
|
|
|
updatedFileName: "", |
|
|
|
|
|
|
|
current: "", |
|
|
|
|
|
|
|
past: "", |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
return filediff; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => { |
|
|
|
export const getCommitChanges = async (oid1: string, oid2: string, branch?: branch, remote?: remote) => { |
|
|
@ -793,57 +747,22 @@ export const fetchBranch = async (branch: branch, page: number) => { |
|
|
|
console.log(rc, 'remote commits from octokit') |
|
|
|
console.log(rc, 'remote commits from octokit') |
|
|
|
dispatch(setRemoteBranchCommits({ branch, commits: rc })) |
|
|
|
dispatch(setRemoteBranchCommits({ branch, commits: rc })) |
|
|
|
return |
|
|
|
return |
|
|
|
const r = await plugin.call('dGitProvider', 'fetch', { |
|
|
|
} |
|
|
|
ref: branch.name, |
|
|
|
|
|
|
|
remoteRef: branch.name, |
|
|
|
|
|
|
|
singleBranch: true, |
|
|
|
|
|
|
|
remote: branch.remote.remote, |
|
|
|
|
|
|
|
depth: 10 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
console.log(branch) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const remoteCommits: ReadCommitResult[] = await plugin.call('dGitProvider', 'log', { |
|
|
|
|
|
|
|
ref: r.fetchHead |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
console.log(r, remoteCommits) |
|
|
|
|
|
|
|
let localCommits: ReadCommitResult[] = [] |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
localCommits = await plugin.call('dGitProvider', 'log', { |
|
|
|
|
|
|
|
ref: branch.name, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
console.log(r, localCommits) |
|
|
|
|
|
|
|
} catch (e) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const remoteCommitsThatAreNotLocal: ReadCommitResult[] = remoteCommits.filter((commit) => { |
|
|
|
export const getBranchDifferences = async (branch: branch, remote: remote, state: gitState) => { |
|
|
|
return !localCommits.find((localCommit) => localCommit.oid === commit.oid) |
|
|
|
if(!remote && state){ |
|
|
|
} |
|
|
|
if(state.defaultRemote){ |
|
|
|
) |
|
|
|
remote = state.defaultRemote |
|
|
|
console.log(remoteCommitsThatAreNotLocal) |
|
|
|
}else{ |
|
|
|
const mergeCommits = remoteCommitsThatAreNotLocal.map((commit) => { |
|
|
|
remote = state.remotes.find((remote: remote) => remote.remote === 'origin') |
|
|
|
return { |
|
|
|
|
|
|
|
...commit, |
|
|
|
|
|
|
|
remote: true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}).concat(localCommits.map((commit) => { |
|
|
|
if(!remote && state.remotes[0]){ |
|
|
|
return { |
|
|
|
remote = state.remotes[0] |
|
|
|
...commit, |
|
|
|
|
|
|
|
remote: false |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
)) |
|
|
|
if(!remote) return |
|
|
|
// sort by date
|
|
|
|
|
|
|
|
mergeCommits.sort((a, b) => { |
|
|
|
|
|
|
|
return new Date(b.commit.committer.timestamp).getTime() - new Date(a.commit.committer.timestamp).getTime() |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log(mergeCommits) |
|
|
|
|
|
|
|
//console.log(r, commits)
|
|
|
|
|
|
|
|
//dispatch(setRemoteBranchCommits({ branch, commits: mergeCommits }))
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const getBranchDifferences = async (branch: branch, remote: remote) => { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
console.log('compare', branch, remote) |
|
|
|
const branchDifference: branchDifference = await plugin.call('dGitProvider', 'compareBranches', { |
|
|
|
const branchDifference: branchDifference = await plugin.call('dGitProvider', 'compareBranches', { |
|
|
|
branch, |
|
|
|
branch, |
|
|
|
remote |
|
|
|
remote |
|
|
|