@ -2,7 +2,7 @@ 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 , setRateLimit , setRemoteBranches , setRemotes , setRepos , setUpstream , setLocalBranchCommits , setBranchDifferences , setRemoteAsDefault , setScopes , setLog , clearLog } from "../state/gitpayload" ;
import { fileStatus , fileStatusMerge , setRemoteBranchCommits , resetRemoteBranchCommits , setBranches , setCanCommit , setCommitChanges , setCommits , setCurrentBranch , setGitHubUser , setLoading , setRateLimit , setRemoteBranches , setRemotes , setRepos , setUpstream , setLocalBranchCommits , setBranchDifferences , setRemoteAsDefault , setScopes , setLog , clearLog } from "../state/gitpayload" ;
import { GitHubUser , RateLimit , branch , commitChange , gitActionDispatch , statusMatrixType , gitState , branchDifference , remote , gitLog , fileStatusResult , customGitApi , customDGitSystem , cloneInputType , fetchInputType , pullInputType , pushInputType , checkoutInput , rmInput , addInput , repository } from '../types' ;
import { GitHubUser , RateLimit , branch , commitChange , gitActionDispatch , statusMatrixType , gitState , branchDifference , remote , gitLog , fileStatusResult , customGitApi , IGitApi , cloneInputType , fetchInputType , pullInputType , pushInputType , checkoutInput , rmInput , addInput , repository } 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 { AlertModal , ModalTypes } from "@remix-ui/app" ;
@ -25,7 +25,6 @@ export const fileStatuses = [
[ "modified,staged,with unstaged changes" , 1 , 2 , 3 ] , // modified, staged, with unstaged changes
[ "modified,staged,with unstaged changes" , 1 , 2 , 3 ] , // modified, staged, with unstaged changes
[ "deleted,unstaged" , 1 , 0 , 1 ] , // deleted, unstaged
[ "deleted,unstaged" , 1 , 0 , 1 ] , // deleted, unstaged
[ "deleted,staged" , 1 , 0 , 0 ] ,
[ "deleted,staged" , 1 , 0 , 0 ] ,
//["deleted", 1, 1, 0], // deleted, staged
[ "unmodified" , 1 , 1 , 3 ] ,
[ "unmodified" , 1 , 1 , 3 ] ,
[ "deleted,not in git" , 0 , 0 , 3 ] ,
[ "deleted,not in git" , 0 , 0 , 3 ] ,
[ "unstaged,modified" , 1 , 2 , 0 ]
[ "unstaged,modified" , 1 , 2 , 0 ]
@ -162,10 +161,10 @@ export const getCommitFromRef = async (ref: string) => {
}
}
const settingsWarning = async ( ) = > {
const settingsWarning = async ( ) = > {
const username = await plugin . call ( 'config' as any , 'getAppParameter' , 'settings/github-user-name' )
const username = await plugin . call ( 'config' , 'getAppParameter' , 'settings/github-user-name' )
const email = await plugin . call ( 'config' as any , 'getAppParameter' , 'settings/github-email' )
const email = await plugin . call ( 'config' , 'getAppParameter' , 'settings/github-email' )
if ( ! username || ! email ) {
if ( ! username || ! email ) {
plugin . call ( 'notification' as any , 'toast' , 'Please set your github username and email in the settings' )
plugin . call ( 'notification' , 'toast' , 'Please set your github username and email in the settings' )
return false ;
return false ;
} else {
} else {
return {
return {
@ -198,7 +197,7 @@ export const commit = async (message: string = "") => {
} )
} )
} catch ( err ) {
} catch ( err ) {
plugin . call ( 'notification' as any , 'toast' , ` ${ err } ` )
plugin . call ( 'notification' , 'toast' , ` ${ err } ` )
}
}
}
}
@ -216,7 +215,7 @@ export const addall = async (files: fileStatusResult[]) => {
} )
} )
} catch ( e ) {
} catch ( e ) {
plugin . call ( 'notification' as any , 'toast' , ` ${ e } ` )
plugin . call ( 'notification' , 'toast' , ` ${ e } ` )
}
}
}
}
@ -228,7 +227,7 @@ export const add = async (filepath: addInput) => {
message : ` Added to git `
message : ` Added to git `
} )
} )
} catch ( e ) {
} catch ( e ) {
plugin . call ( 'notification' as any , 'toast' , ` ${ e } ` )
plugin . call ( 'notification' , 'toast' , ` ${ e } ` )
}
}
}
}
@ -275,7 +274,7 @@ export const checkoutfile = async (filename: string) => {
) ;
) ;
await enableCallBacks ( ) ;
await enableCallBacks ( ) ;
} catch ( e ) {
} catch ( e ) {
plugin . call ( 'notification' as any , 'toast' , ` No such file ` )
plugin . call ( 'notification' , 'toast' , ` No such file ` )
}
}
}
}
@ -287,7 +286,7 @@ export const checkout = async (cmd: checkoutInput) => {
await plugin . call ( 'dgitApi' , 'checkout' , cmd )
await plugin . call ( 'dgitApi' , 'checkout' , cmd )
gitlog ( ) ;
gitlog ( ) ;
} catch ( e ) {
} catch ( e ) {
plugin . call ( 'notification' as any , 'toast' , ` ${ e } ` )
plugin . call ( 'notification' , 'toast' , ` ${ e } ` )
}
}
await enableCallBacks ( ) ;
await enableCallBacks ( ) ;
}
}
@ -376,7 +375,7 @@ const parseError = async (e: any) => {
console . trace ( e )
console . trace ( e )
// if message conttains 401 Unauthorized, show token warning
// if message conttains 401 Unauthorized, show token warning
if ( e . message . includes ( '401' ) ) {
if ( e . message . includes ( '401' ) ) {
const result = await plugin . call ( 'notification' as any , 'modal' as any , {
const result = await plugin . call ( 'notification' , 'modal' as any , {
title : 'The GitHub token may be missing or invalid' ,
title : 'The GitHub token may be missing or invalid' ,
message : 'Please check the GitHub token and try again. Error: 401 Unauthorized' ,
message : 'Please check the GitHub token and try again. Error: 401 Unauthorized' ,
okLabel : 'Go to settings' ,
okLabel : 'Go to settings' ,
@ -387,7 +386,7 @@ const parseError = async (e: any) => {
}
}
// 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' ) ) {
await plugin . call ( 'notification' as any , 'modal' as any , {
await plugin . call ( 'notification' , 'modal' as any , {
title : 'Repository not found' ,
title : 'Repository not found' ,
message : 'Please check the URL and try again.' ,
message : 'Please check the URL and try again.' ,
okLabel : 'Go to settings' ,
okLabel : 'Go to settings' ,
@ -397,7 +396,7 @@ const parseError = async (e: any) => {
}
}
// if message contains 403 Forbidden
// if message contains 403 Forbidden
else if ( e . message . includes ( '403' ) ) {
else if ( e . message . includes ( '403' ) ) {
await plugin . call ( 'notification' as any , 'modal' as any , {
await plugin . call ( 'notification' , 'modal' as any , {
title : 'The GitHub token may be missing or invalid' ,
title : 'The GitHub token may be missing or invalid' ,
message : 'Please check the GitHub token and try again. Error: 403 Forbidden' ,
message : 'Please check the GitHub token and try again. Error: 403 Forbidden' ,
okLabel : 'Go to settings' ,
okLabel : 'Go to settings' ,
@ -405,14 +404,14 @@ const parseError = async (e: any) => {
type : ModalTypes . confirm
type : ModalTypes . confirm
} )
} )
} else if ( e . toString ( ) . includes ( 'NotFoundError' ) && ! e . toString ( ) . includes ( 'fetch' ) ) {
} else if ( e . toString ( ) . includes ( 'NotFoundError' ) && ! e . toString ( ) . includes ( 'fetch' ) ) {
await plugin . call ( 'notification' as any , 'modal' , {
await plugin . call ( 'notification' , 'modal' , {
title : 'Remote branch not found' ,
title : 'Remote branch not found' ,
message : 'The branch you are trying to fetch does not exist on the remote. If you have forked this branch from another branch, you may need to fetch the original branch first or publish this branch on the remote.' ,
message : 'The branch you are trying to fetch does not exist on the remote. If you have forked this branch from another branch, you may need to fetch the original branch first or publish this branch on the remote.' ,
okLabel : 'OK' ,
okLabel : 'OK' ,
type : ModalTypes . alert
type : ModalTypes . alert
} )
} )
} else {
} else {
await plugin . call ( 'notification' as any , 'alert' as any , {
await plugin . call ( 'notification' , 'alert' as any , {
title : 'Error' ,
title : 'Error' ,
message : e.message
message : e.message
} )
} )
@ -439,7 +438,7 @@ export const repositories = async () => {
}
}
} else {
} else {
plugin . call ( 'notification' as any , 'alert' , {
plugin . call ( 'notification' , 'alert' , {
title : 'Error getting repositories' ,
title : 'Error getting repositories' ,
message : ` Please check your GitHub token in the GitHub settings... cannot connect to GitHub `
message : ` Please check your GitHub token in the GitHub settings... cannot connect to GitHub `
} )
} )
@ -447,7 +446,7 @@ export const repositories = async () => {
}
}
} catch ( e ) {
} catch ( e ) {
console . log ( e )
console . log ( e )
plugin . call ( 'notification' as any , 'alert' , {
plugin . call ( 'notification' , 'alert' , {
title : 'Error getting repositories' ,
title : 'Error getting repositories' ,
message : ` ${ e . message } : Please check your GitHub token in the GitHub settings. `
message : ` ${ e . message } : Please check your GitHub token in the GitHub settings. `
} )
} )
@ -474,7 +473,7 @@ export const remoteBranches = async (owner: string, repo: string) => {
page ++
page ++
}
}
} else {
} else {
plugin . call ( 'notification' as any , 'alert' , {
plugin . call ( 'notification' , 'alert' , {
title : 'Error getting branches' ,
title : 'Error getting branches' ,
message : ` Please check your GitHub token in the GitHub settings. It needs to have access to the branches. `
message : ` Please check your GitHub token in the GitHub settings. It needs to have access to the branches. `
} )
} )
@ -482,7 +481,7 @@ export const remoteBranches = async (owner: string, repo: string) => {
}
}
} catch ( e ) {
} catch ( e ) {
console . log ( e )
console . log ( e )
plugin . call ( 'notification' as any , 'alert' , {
plugin . call ( 'notification' , 'alert' , {
title : 'Error' ,
title : 'Error' ,
message : e.message
message : e.message
} )
} )
@ -516,7 +515,7 @@ export const remoteCommits = async (url: string, branch: string, length: number)
}
}
} catch ( e ) {
} catch ( e ) {
console . log ( e )
console . log ( e )
plugin . call ( 'notification' as any , 'alert' , {
plugin . call ( 'notification' , 'alert' , {
title : 'Error' ,
title : 'Error' ,
message : e.message
message : e.message
} )
} )