Skip to main content

Git API

The git module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
addAllAdds changes in the local repository to the staging area at the given path.
branchCreates a new branch in the local repository at the given path.
checkoutChecks out a branch or commit in the local repository at the given path.
cloneClones a remote Git repository to the specified path.
commitCommits the staged changes in the local repository with the given commit message.
diffRetrieves the diff of changes for a specific commit in the local repository.
initInitializes a new Git repository at the given path.
logsRetrieves the commit logs for the local repository at the given path.
pullPulls the latest changes from the remote repository to the local repository at the given path.
pushPushes local repository changes to the remote repository at the given path.
statusRetrieves the status of the local repository at the given path.

Methods


addAll

plugin.git.addAll(): Promise<AddResponse>

Adds changes in the local repository to the staging area at the given path.

No parameters.

Returns: Promise<AddResponse> — A promise that resolves with the response from the add event.

Full reference →


branch

plugin.git.branch(branch: string): Promise<GitBranchResponse>

Creates a new branch in the local repository at the given path.

ParameterTypeRequiredDescription
branchstringYesThe name of the new branch to create.

Returns: Promise<GitBranchResponse> — A promise that resolves with the response from the branch event.

Full reference →


checkout

plugin.git.checkout(branch: string): Promise<GitCheckoutResponse>

Checks out a branch or commit in the local repository at the given path.

ParameterTypeRequiredDescription
branchstringYesThe name of the branch or commit to check out.

Returns: Promise<GitCheckoutResponse> — A promise that resolves with the response from the checkout event.

Full reference →


clone

plugin.git.clone(url: string, path?: string): Promise<GitCloneResponse>

Clones a remote Git repository to the specified path.

ParameterTypeRequiredDescription
urlstringYesThe URL of the remote repository to clone.
pathstringNoThe file system path where the repository should be cloned.

Returns: Promise<GitCloneResponse> — A promise that resolves with the response from the clone event.

Full reference →


commit

plugin.git.commit(message: string): Promise<GitCommitResponse>

Commits the staged changes in the local repository with the given commit message.

ParameterTypeRequiredDescription
messagestringYesThe commit message to use for the commit.

Returns: Promise<GitCommitResponse> — A promise that resolves with the response from the commit event.

Full reference →


diff

plugin.git.diff(commitHash: string): Promise<GitDiffResponse>

Retrieves the diff of changes for a specific commit in the local repository.

ParameterTypeRequiredDescription
commitHashstringYesThe hash of the commit to retrieve the diff for.

Returns: Promise<GitDiffResponse> — A promise that resolves with the response from the diff event.

Full reference →


init

plugin.git.init(path: string): Promise<GitInitResponse>

Initializes a new Git repository at the given path.

ParameterTypeRequiredDescription
pathstringYesThe file system path where the Git repository should be initialized.

Returns: Promise<GitInitResponse> — A promise that resolves with the response from the init event.

Full reference →


logs

plugin.git.logs(path: string): Promise<GitLogsResponse>

Retrieves the commit logs for the local repository at the given path.

ParameterTypeRequiredDescription
pathstringYesThe file system path of the local Git repository.

Returns: Promise<GitLogsResponse> — A promise that resolves with the response from the logs event.

Full reference →


pull

plugin.git.pull(): Promise<GitPullResponse>

Pulls the latest changes from the remote repository to the local repository at the given path.

No parameters.

Returns: Promise<GitPullResponse> — A promise that resolves with the response from the pull event.

Full reference →


push

plugin.git.push(): Promise<GitPushResponse>

Pushes local repository changes to the remote repository at the given path.

No parameters.

Returns: Promise<GitPushResponse> — A promise that resolves with the response from the push event.

Full reference →


status

plugin.git.status(): Promise<GitStatusResponse>

Retrieves the status of the local repository at the given path.

No parameters.

Returns: Promise<GitStatusResponse> — A promise that resolves with the response from the status event.

Full reference →