oneRepo API: git
Special handlers for managing complex queries and manipulation of the git repository’s state.
Classes
Section titled ClassesStagingWorkflow
Section titled StagingWorkflowConstructors
Section titled Constructorsnew StagingWorkflow(options)
Section titled new StagingWorkflow(options)Parameters:
Parameter | Type | Description |
---|---|---|
options | Object | - |
options.graph | Graph | The repository Graph |
options.logger | Logger | Logger instance to use for all actions |
Returns: StagingWorkflow
Source: modules/git/src/workflow.ts
Methods
Section titled MethodsrestoreUnstaged()
Section titled restoreUnstaged()Restores the unstaged changes previously backed up by saveUnstaged()
.
This command will go through a series of attempts to ressurect upon failure, eventually throwing an error if unstaged changes cannot be reapplied.
Returns: Promise
<void
>
Source: modules/git/src/workflow.ts
saveUnstaged()
Section titled saveUnstaged()Backup any unstaged changes, whether that’s full files or parts of files. This will result in the git status only including what was already in the stage. All other changes will be backed up to:
- A patch file in the
.git/
directory - A git stash
To restore the unstaged changes, call restoreUnstaged()
.
Returns: Promise
<void
>
Source: modules/git/src/workflow.ts
Type Aliases
Section titled Type AliasesModifiedFromThrough
Section titled ModifiedFromThroughType declaration
Section titled Type declarationfrom?
Section titled from?Git ref for start (exclusive) to get list of modified files
staged?
Section titled staged?Cannot include staged
files when using from/through refs.
through?
Section titled through?Git ref for end (inclusive) to get list of modified files
Source: modules/git/src/index.ts
ModifiedStaged
Section titled ModifiedStagedType declaration
Section titled Type declarationfrom?
Section titled from?Disallowed when staged: true
staged
Section titled stagedGet staged modified files only
through?
Section titled through?Disallowed when staged: true
Source: modules/git/src/index.ts
Options
Section titled OptionsGeneric options passed to all Git operations.
Type declaration
Section titled Type declarationstep?
Section titled step?Avoid creating a new step in output for each function. Pass a Logger Step to pipe all logs and output to that instead.
Source: modules/git/src/index.ts
UpdateIndexOptions
Section titled UpdateIndexOptionsType declaration
Section titled Type declarationimmediately?
Section titled immediately?Set whether to immediately add to the git index or defer until process shutdown
Default: false
Source: modules/git/src/index.ts
Functions
Section titled FunctionsflushUpdateIndex()
Section titled flushUpdateIndex()Write all pending files added using updateIndex()
to the git index.
Parameters:
Parameter | Type |
---|---|
options ? | Options |
Returns: Promise
<void
>
Source: modules/git/src/index.ts
getBranch()
Section titled getBranch()Get the name of the current branch. Equivalent to git rev-parse --abbrev-ref HEAD
.
Parameters:
Parameter | Type |
---|---|
options ? | Options |
Returns: Promise
<string
>
Source: modules/git/src/index.ts
getCurrentSha()
Section titled getCurrentSha()Get the current sha ref. This is equivalent to git rev-parse HEAD
.
Parameters:
Parameter | Type |
---|---|
options ? | Options |
Returns: Promise
<string
>
Source: modules/git/src/index.ts
getMergeBase()
Section titled getMergeBase()Determine the git ref for merging the current working branch, sha, or ref, whichever that is. This function does a bunch of internal checks to determine the where the most likely point of forking happened.
Parameters:
Parameter | Type |
---|---|
options ? | Options |
Returns: Promise
<string
>
Source: modules/git/src/index.ts
getModifiedFiles()
Section titled getModifiedFiles()Get a map of the currently modified files based on their status. If from
and through
are not provided, this will current merge-base determination to best get the change to the working tree using git diff
and git diff-tree
.
Parameters:
Parameter | Type |
---|---|
modified ? | ModifiedStaged | ModifiedFromThrough |
options ? | Options |
Returns: Promise
<string
[]>
Source: modules/git/src/index.ts
isClean()
Section titled isClean()Check if the current git working state is clean.
Parameters:
Parameter | Type |
---|---|
options ? | Options |
Returns: Promise
<boolean
>
Source: modules/git/src/index.ts
updateIndex()
Section titled updateIndex()Add filepaths to the git index. Equivalent to git add [...files]
. By default, this method will track the files that need to be added to the git index. It will only add files immediately if given the immediately
option.
Use flushUpdateIndex()
to write all tracked files the git index. This method is automatically called during the oneRepo command shutdown process, so you may not ever need to call this.
It is best to avoid immediately adding items to the git index to avoid race conditions which can drop git into a bad state, requiring users to manually delete their .git/index.lock
file before continuing.
Parameters:
Parameter | Type |
---|---|
paths | string | string [] |
options ? | UpdateIndexOptions |
Returns: Promise
<string
| undefined
>
Source: modules/git/src/index.ts