GitInteraction

git-casefile/impl. GitInteraction

new GitInteraction()

Class encapsulating usage of git

Source:

Methods

(async) deleteCasefilePaths(remote, paths)

Delete selected paths from the casefile set in a remote repository

Source:
Parameters:
Name Type Description
remote string
paths Array.<string>

(async) fetchFromRemote(remote) → {Promise.<undefined>}

Fetch new Git objects from the named remote

Source:
Parameters:
Name Type Description
remote string
Returns:
Type
Promise.<undefined>

(async) fetchSharedCasefilesFromRemote(remoteName) → {Promise.<null>}

Fetch the current set of shared casefiles from the named remote

Source:
Parameters:
Name Type Description
remoteName string

Name of remote to consult

Returns:

No real return value

Type
Promise.<null>

(async) findCurrentLinePosition(filePath, location, contentopt) → {Promise.<{line: number}>}

Find the current line position from a historic line reference

Source:
Parameters:
Name Type Attributes Description
filePath string

The path to the file/blob within the repository whose history to search

location object
Properties
Name Type Description
commit string

The commit hash establishing the context for location.line

line number

The line within filePath at commit location.commit for which to search within content

content string <optional>

The current content in which to search; on-disk content of filePath used if not specified

Returns:
Type
Promise.<{line: number}>

(async) getBlobContent(path, optsopt) → {Promise.<string>}

Retrieve the content of a blob from the repository

Source:
Parameters:
Name Type Attributes Description
path string

Path of the blob within the committish tree

opts object <optional>
Properties
Name Type Attributes Description
commit string <optional>

The commit (or committish) from which to retrieve the blob

Returns:

Blob contents

Type
Promise.<string>

(async) getCasefile(path, opts) → {Promise.<Object>}

Retrieve the content of a casefile

Source:
Parameters:
Name Type Description
path string

Path of casefile instance

opts object
Properties
Name Type Description
beforeCommit string

A latest, open bound on the commit to read

Returns:

Casefile data

Type
Promise.<Object>

(async) getCasefileAuthors(path) → {Promise.<{path: string, authors: Array.<string>}>}

Get a list of all authors for a specified casefile instance

Source:
Parameters:
Name Type Description
path string

Path of instance within the sharedCasefilesRef

Returns:
Type
Promise.<{path: string, authors: Array.<string>}>

(async) getDeletedCasefileRefs(partialopt) → {Promise.<Array.<{commit: string, committed: Date, path: string}>>}

Look up information on deleted casefiles from the repo history

Source:
Parameters:
Name Type Attributes Description
partial string <optional>

A substring found within the casefile group name

Returns:
Type
Promise.<Array.<{commit: string, committed: Date, path: string}>>

(async) getListOfCasefiles() → {Promise.<Array.<{name: string, instances: Array.<{path: string}>}>>}

Get a list of casefiles known locally

Source:
Returns:
Type
Promise.<Array.<{name: string, instances: Array.<{path: string}>}>>

(async) getListOfRemotes() → {Promise.<Array.<string>>}

Retrieve a list of configured Git remotes

Source:
Returns:

Remote names/aliases

Type
Promise.<Array.<string>>

(async) lineIntroduction(filePath, line, optsopt) → {Promise.<{commit: string, line: number}>}

Find the commit and line at which the given line was added to the file

Source:

This method searches within the repository to find the commit at which a certain line was introduced into filePath, and the line number this line had at the time it was introduced.

The reference content to which line refers can come from one of three options, given here in order of precedence:

  • If opts.commit is specified, the contents of filePath at opts.commit constitute the reference content.
  • If opts.liveContent is specified, opts.liveContent is the reference content.
  • Otherwise, the content of filePath on the disk is the reference content.
Parameters:
Name Type Attributes Description
filePath string

The path to the file/blob within the repository whose history to search

line number

The line number (1-based) within the reference content for filePath for whose introduction to search

opts object <optional>
Properties
Name Type Attributes Description
commit string <optional>

Commit (or committish) with content for filePath in which to start the search

liveContent string <optional>

Current, unsaved content of filePath; has no effect when specified if opts.commit is also specified

Throws:

(code === 'NoCommitFound') When no commit is reported by Git as the origin for line in filePath

Type
GitInterationError
Returns:

The commit and line at which line in the reference content was introduced into filePath in the repository

Type
Promise.<{commit: string, line: number}>

(async) lsTree(treeish) → {Promise.<Array.<TreeEntry>>}

List the contents of a Git tree

Source:
Parameters:
Name Type Description
treeish string

A Git tree-ish value, often a reference to a commit

Returns:
Type
Promise.<Array.<TreeEntry>>

(async) mktree(entries) → {Promise.<string>}

Create a tree object from a list of entries

Source:
Parameters:
Name Type Description
entries Array.<TreeEntry>
Throws:

(err.code === 'InvalidTreeResult') When Git does not return a valid value

Type
GitInterationError
Returns:

Hash of tree

Type
Promise.<string>

(async) push(remote, …specs) → {Promise.<null>}

Push a commit to a named reference on a remote

Source:

This method pushes specs to remote; each item of specs can be either a string (which serves as both source name and destination branch name, and is not forced) or a PushSpec object. This is similar to the simple and full syntaxes of the command line git push command, though use of PushSpec objects is recommended for clarity.

Parameters:
Name Type Attributes Description
remote string
specs PushSpec | string <repeatable>

What to push

Returns:
Type
Promise.<null>

(async) revParse(committish) → {Promise.<string>}

Parse the given committish to find the hash to which it resolves

Source:
Parameters:
Name Type Description
committish string
Throws:

(err.code === 'InvalidCommittish') When Git returns an invalid result

Type
GitInterationError
Returns:

Commit hash

Type
Promise.<string>

(async) selectCommitsUnknownToRemote(remote, commits) → {Promise.<Array.<string>>}

Find commits that are not known by the stated remote

Source:

This method indirectly expects that the pull configuration for remote behaves is the default way with regard to creating remote-tracking branches in refs/remotes/REMOTE-NAME for a remote named REMOTE-NAME.

Parameters:
Name Type Description
remote string

Name of remote to work with

commits Array.<string>

Commits to consider

Returns:

Commits not found in the history of any branch shared by remote

Type
Promise.<Array.<string>>

(async) shareCasefile(remote, path, bookmarks) → {Promise.<{message: string, commit: ?string}>}

Share a casefile with the given remote repository

Source:
Parameters:
Name Type Description
remote string
path string

Group-slash-instance to store under

bookmarks Array.<object>

JSON-serializable bookmark data

Returns:
Type
Promise.<{message: string, commit: ?string}>

(async) updateRef(refName, commit) → {Promise.<null>}

Safely update a named reference in the repository

Source:
Parameters:
Name Type Description
refName string
commit string

New value for refName

Returns:
Type
Promise.<null>