git-sync-js / inspect
Module: inspect
Table of contents
Interfaces
Type Aliases
Functions
- assumeSync
- getDefaultBranchName
- getGitDirectory
- getGitRepositoryState
- getModifiedFileList
- getRemoteName
- getRemoteRepoName
- getRemoteUrl
- getSyncState
- hasGit
- haveLocalChanges
Type Aliases
SyncState
Ƭ SyncState: "noUpstreamOrBareUpstream"
| "equal"
| "ahead"
| "behind"
| "diverged"
Defined in
Functions
assumeSync
▸ assumeSync(wikiFolderPath
, defaultBranchName
, remoteName
, logger?
): Promise
<void
>
Parameters
Name | Type |
---|---|
wikiFolderPath | string |
defaultBranchName | string |
remoteName | string |
logger? | ILogger |
Returns
Promise
<void
>
Defined in
getDefaultBranchName
▸ getDefaultBranchName(wikiFolderPath
): Promise
<string
| undefined
>
Get "master" or "main" from git repo
Parameters
Name | Type |
---|---|
wikiFolderPath | string |
Returns
Promise
<string
| undefined
>
Defined in
getGitDirectory
▸ getGitDirectory(dir
, logger?
): Promise
<string
>
echo the git dir
Parameters
Name | Type | Description |
---|---|---|
dir | string | repo path |
logger? | ILogger | - |
Returns
Promise
<string
>
Defined in
getGitRepositoryState
▸ getGitRepositoryState(wikiFolderPath
, logger?
): Promise
<string
>
get various repo state in string format
Parameters
Name | Type | Description |
---|---|---|
wikiFolderPath | string | repo path to check |
logger? | ILogger | - |
Returns
Promise
<string
>
gitState // TODO: use template literal type to get exact type of git state
Defined in
getModifiedFileList
▸ getModifiedFileList(wikiFolderPath
): Promise
<ModifiedFileList
[]>
Get modified files and modify type in a folder
Parameters
Name | Type | Description |
---|---|---|
wikiFolderPath | string | location to scan git modify state |
Returns
Promise
<ModifiedFileList
[]>
Defined in
getRemoteName
▸ getRemoteName(dir
, branch
): Promise
<string
>
get things like "origin"
Parameters
Name | Type |
---|---|
dir | string |
branch | string |
Returns
Promise
<string
>
Defined in
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
Name | Type | Description |
---|---|---|
remoteUrl | string | full github repository url or other repository url |
Returns
string
| undefined
Defined in
getRemoteUrl
▸ getRemoteUrl(dir
, remoteName
): Promise
<string
>
Inspect git's remote url from folder's .git config
Parameters
Name | Type | Description |
---|---|---|
dir | string | wiki folder path, git folder to inspect |
remoteName | string | - |
Returns
Promise
<string
>
remote url, without '.git'
Example
Defined in
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
Name | Type | Description |
---|---|---|
dir | string | repo path to test |
defaultBranchName | string | - |
remoteName | string | - |
logger? | ILogger | - |
Returns
Promise
<SyncState
>
Defined in
hasGit
▸ hasGit(dir
, strict?
): Promise
<boolean
>
Check if dir has .git
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
dir | string | undefined | folder that may contains a git |
strict | boolean | true | if is true, then dir should be the root of the git repo. Default is true |
Returns
Promise
<boolean
>
Defined in
haveLocalChanges
▸ haveLocalChanges(wikiFolderPath
): Promise
<boolean
>
See if there is any file not being committed
Parameters
Name | Type | Description |
---|---|---|
wikiFolderPath | string | repo path to test |
Returns
Promise
<boolean
>
Example