|
|
@ -42,26 +42,25 @@ let plugin: Plugin<any, CustomRemixApi>, dispatch: React.Dispatch<gitActionDispa |
|
|
|
export const setPlugin = (p: Plugin, dispatcher: React.Dispatch<gitActionDispatch>) => { |
|
|
|
export const setPlugin = (p: Plugin, dispatcher: React.Dispatch<gitActionDispatch>) => { |
|
|
|
plugin = p |
|
|
|
plugin = p |
|
|
|
dispatch = dispatcher |
|
|
|
dispatch = dispatcher |
|
|
|
console.log('setPlugin') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const init = async () => { |
|
|
|
export const init = async () => { |
|
|
|
console.log('gitInit') |
|
|
|
|
|
|
|
await plugin.call('dgitApi', "init"); |
|
|
|
await plugin.call('dgitApi', "init"); |
|
|
|
await gitlog(); |
|
|
|
await gitlog(); |
|
|
|
await getBranches(); |
|
|
|
await getBranches(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const getBranches = async () => { |
|
|
|
export const getBranches = async () => { |
|
|
|
console.log('getBranches') |
|
|
|
|
|
|
|
const branches = await plugin.call('dgitApi', "branches") |
|
|
|
const branches = await plugin.call('dgitApi', "branches") |
|
|
|
console.log('branches :>>', branches) |
|
|
|
|
|
|
|
dispatch(setBranches(branches)); |
|
|
|
dispatch(setBranches(branches)); |
|
|
|
} |
|
|
|
} |
|
|
|
export const getRemotes = async () => { |
|
|
|
export const getRemotes = async () => { |
|
|
|
console.log('getRemotes') |
|
|
|
|
|
|
|
const remotes: remote[] = await plugin.call('dgitApi', "remotes"); |
|
|
|
const remotes: remote[] = await plugin.call('dgitApi', "remotes"); |
|
|
|
console.log('remotes :>>', remotes) |
|
|
|
|
|
|
|
dispatch(setRemotes(remotes)); |
|
|
|
dispatch(setRemotes(remotes)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -89,8 +88,7 @@ export const getFileStatusMatrix = async (filepaths: string[]) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const getCommits = async () => { |
|
|
|
export const getCommits = async () => { |
|
|
|
//Utils.log("get commits");
|
|
|
|
|
|
|
|
console.log('getCommits') |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const commits: ReadCommitResult[] = await plugin.call( |
|
|
|
const commits: ReadCommitResult[] = await plugin.call( |
|
|
|
'dgitApi', |
|
|
|
'dgitApi', |
|
|
@ -117,7 +115,7 @@ export const gitlog = async () => { |
|
|
|
export const showCurrentBranch = async () => { |
|
|
|
export const showCurrentBranch = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const branch = await currentBranch(); |
|
|
|
const branch = await currentBranch(); |
|
|
|
console.log('branch :>>', branch) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(setCanCommit((branch && branch.name !== ""))); |
|
|
|
dispatch(setCanCommit((branch && branch.name !== ""))); |
|
|
|
dispatch(setCurrentBranch(branch)); |
|
|
|
dispatch(setCurrentBranch(branch)); |
|
|
@ -279,7 +277,7 @@ export const checkoutfile = async (filename: string) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const checkout = async (cmd: checkoutInput) => { |
|
|
|
export const checkout = async (cmd: checkoutInput) => { |
|
|
|
console.log(cmd) |
|
|
|
|
|
|
|
await disableCallBacks(); |
|
|
|
await disableCallBacks(); |
|
|
|
await plugin.call('fileManager', 'closeAllFiles') |
|
|
|
await plugin.call('fileManager', 'closeAllFiles') |
|
|
|
try { |
|
|
|
try { |
|
|
@ -492,7 +490,7 @@ export const remoteBranches = async (owner: string, repo: string) => { |
|
|
|
export const remoteCommits = async (url: string, branch: string, length: number) => { |
|
|
|
export const remoteCommits = async (url: string, branch: string, length: number) => { |
|
|
|
const urlParts = url.split("/"); |
|
|
|
const urlParts = url.split("/"); |
|
|
|
|
|
|
|
|
|
|
|
console.log(urlParts, 'urlParts') |
|
|
|
|
|
|
|
// check if it's github
|
|
|
|
// check if it's github
|
|
|
|
if (!urlParts[urlParts.length - 3].includes('github')) { |
|
|
|
if (!urlParts[urlParts.length - 3].includes('github')) { |
|
|
|
return |
|
|
|
return |
|
|
@ -504,9 +502,9 @@ export const remoteCommits = async (url: string, branch: string, length: number) |
|
|
|
try { |
|
|
|
try { |
|
|
|
const token = await tokenWarning(); |
|
|
|
const token = await tokenWarning(); |
|
|
|
if (token) { |
|
|
|
if (token) { |
|
|
|
console.log(token, owner, repo, branch, length) |
|
|
|
|
|
|
|
const commits = await plugin.call('dgitApi' as any, 'remotecommits', { token, owner, repo, branch, length }); |
|
|
|
const commits = await plugin.call('dgitApi' as any, 'remotecommits', { token, owner, repo, branch, length }); |
|
|
|
console.log(commits, 'remote commits') |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
sendToGitLog({ |
|
|
|
sendToGitLog({ |
|
|
|
type: 'error', |
|
|
|
type: 'error', |
|
|
@ -523,7 +521,7 @@ export const remoteCommits = async (url: string, branch: string, length: number) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const saveGitHubCredentials = async (credentials: { username: string, email: string, token: string }) => { |
|
|
|
export const saveGitHubCredentials = async (credentials: { username: string, email: string, token: string }) => { |
|
|
|
console.log('saveGitHubCredentials', credentials) |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') |
|
|
|
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') |
|
|
|
const storedUsername = await plugin.call('config', 'getAppParameter', 'settings/github-user-name') |
|
|
|
const storedUsername = await plugin.call('config', 'getAppParameter', 'settings/github-user-name') |
|
|
@ -566,9 +564,9 @@ export const loadGitHubUserFromToken = async () => { |
|
|
|
emails: userEmails |
|
|
|
emails: userEmails |
|
|
|
} = await plugin.call('dgitApi' as any, 'getGitHubUser', { token }); |
|
|
|
} = await plugin.call('dgitApi' as any, 'getGitHubUser', { token }); |
|
|
|
|
|
|
|
|
|
|
|
console.log('GET USER"', data) |
|
|
|
|
|
|
|
if (data && data.emails && data.user && data.user.login) { |
|
|
|
if (data && data.emails && data.user && data.user.login) { |
|
|
|
console.log('SET USER"', data) |
|
|
|
|
|
|
|
const primaryEmail = data.emails.find(email => email.primary) |
|
|
|
const primaryEmail = data.emails.find(email => email.primary) |
|
|
|
|
|
|
|
|
|
|
|
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') |
|
|
|
const storedEmail = await plugin.call('config', 'getAppParameter', 'settings/github-email') |
|
|
@ -635,7 +633,7 @@ export const diff = async (commitChange: commitChange) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const modifiedContent = Buffer.from(modifiedContentReadBlobResult.blob).toString("utf8"); |
|
|
|
const modifiedContent = Buffer.from(modifiedContentReadBlobResult.blob).toString("utf8"); |
|
|
|
console.log(modifiedContent) |
|
|
|
|
|
|
|
commitChange.modified = modifiedContent; |
|
|
|
commitChange.modified = modifiedContent; |
|
|
|
commitChange.readonly = true; |
|
|
|
commitChange.readonly = true; |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
@ -650,7 +648,7 @@ export const diff = async (commitChange: commitChange) => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const originalContent = Buffer.from(originalContentReadBlobResult.blob).toString("utf8"); |
|
|
|
const originalContent = Buffer.from(originalContentReadBlobResult.blob).toString("utf8"); |
|
|
|
console.log(originalContent) |
|
|
|
|
|
|
|
commitChange.original = originalContent; |
|
|
|
commitChange.original = originalContent; |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
commitChange.original = ""; |
|
|
|
commitChange.original = ""; |
|
|
@ -668,14 +666,14 @@ export const getCommitChanges = async (oid1: string, oid2: string, branch?: bran |
|
|
|
log = await plugin.call('dgitApi', 'log', { |
|
|
|
log = await plugin.call('dgitApi', 'log', { |
|
|
|
ref: branch ? branch.name : 'HEAD', |
|
|
|
ref: branch ? branch.name : 'HEAD', |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(log, 'log') |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.log(e, 'log error') |
|
|
|
console.log(e, 'log error') |
|
|
|
} |
|
|
|
} |
|
|
|
if (log) { |
|
|
|
if (log) { |
|
|
|
const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2) |
|
|
|
const foundCommit = log.find((commit: ReadCommitResult) => commit.oid === oid2) |
|
|
|
if (!foundCommit && remote) { |
|
|
|
if (!foundCommit && remote) { |
|
|
|
console.log('getCommitChanges fetching remote') |
|
|
|
|
|
|
|
//await fetch(remote ? remote.name : null, branch ? branch.name : null, null, 5, true, true)
|
|
|
|
//await fetch(remote ? remote.name : null, branch ? branch.name : null, null, 5, true, true)
|
|
|
|
await fetch({ |
|
|
|
await fetch({ |
|
|
|
remote: remote, |
|
|
|
remote: remote, |
|
|
|