Skip to main content

git-sync-js / inspect

Module: inspect

Table of contents

Interfaces

Type Aliases

Functions

Type Aliases

SyncState

Ƭ SyncState: "noUpstreamOrBareUpstream" | "equal" | "ahead" | "behind" | "diverged"

Defined in

src/inspect.ts:137

Functions

assumeSync

assumeSync(wikiFolderPath, defaultBranchName, remoteName, logger?): Promise<void>

Parameters

NameType
wikiFolderPathstring
defaultBranchNamestring
remoteNamestring
logger?ILogger

Returns

Promise<void>

Defined in

src/inspect.ts:186


getDefaultBranchName

getDefaultBranchName(wikiFolderPath): Promise<string | undefined>

Get "master" or "main" from git repo

https://github.com/simonthum/git-sync/blob/31cc140df2751e09fae2941054d5b61c34e8b649/git-sync#L228-L232

Parameters

NameType
wikiFolderPathstring

Returns

Promise<string | undefined>

Defined in

src/inspect.ts:119


getGitDirectory

getGitDirectory(dir, logger?): Promise<string>

echo the git dir

Parameters

NameTypeDescription
dirstringrepo path
logger?ILogger-

Returns

Promise<string>

Defined in

src/inspect.ts:260


getGitRepositoryState

getGitRepositoryState(wikiFolderPath, logger?): Promise<string>

get various repo state in string format

Parameters

NameTypeDescription
wikiFolderPathstringrepo path to check
logger?ILogger-

Returns

Promise<string>

gitState // TODO: use template literal type to get exact type of git state

Defined in

src/inspect.ts:200


getModifiedFileList

getModifiedFileList(wikiFolderPath): Promise<ModifiedFileList[]>

Get modified files and modify type in a folder

Parameters

NameTypeDescription
wikiFolderPathstringlocation to scan git modify state

Returns

Promise<ModifiedFileList[]>

Defined in

src/inspect.ts:24


getRemoteName

getRemoteName(dir, branch): Promise<string>

get things like "origin"

https://github.com/simonthum/git-sync/blob/31cc140df2751e09fae2941054d5b61c34e8b649/git-sync#L238-L257

Parameters

NameType
dirstring
branchstring

Returns

Promise<string>

Defined in

src/inspect.ts:310


getRemoteRepoName

getRemoteRepoName(remoteUrl): string | undefined

Get the Github Repo Name, which is similar to "linonetwo/wiki", that is the string after "https://github.com/", so we basically just get the pathname of URL.

Parameters

NameTypeDescription
remoteUrlstringfull github repository url or other repository url

Returns

string | undefined

Defined in

src/inspect.ts:86


getRemoteUrl

getRemoteUrl(dir, remoteName): Promise<string>

Inspect git's remote url from folder's .git config

Parameters

NameTypeDescription
dirstringwiki folder path, git folder to inspect
remoteNamestring-

Returns

Promise<string>

remote url, without '.git'

Example

Defined in

src/inspect.ts:72


getSyncState

getSyncState(dir, defaultBranchName, remoteName, logger?): Promise<SyncState>

determine sync state of repository, i.e. how the remote relates to our HEAD 'ahead' means our local state is ahead of remote, 'behind' means local state is behind of the remote

Parameters

NameTypeDescription
dirstringrepo path to test
defaultBranchNamestring-
remoteNamestring-
logger?ILogger-

Returns

Promise<SyncState>

Defined in

src/inspect.ts:143


hasGit

hasGit(dir, strict?): Promise<boolean>

Check if dir has .git.

Parameters

NameTypeDefault valueDescription
dirstringundefinedfolder that may contains a git
strictbooleantrueif is true, then dir should be the root of the git repo. Default is true

Returns

Promise<boolean>

Defined in

src/inspect.ts:291


haveLocalChanges

haveLocalChanges(wikiFolderPath): Promise<boolean>

See if there is any file not being committed

Parameters

NameTypeDescription
wikiFolderPathstringrepo path to test

Returns

Promise<boolean>

Example

Defined in

src/inspect.ts:106