Skip to content

git/client

Documentation

Overview

Classes

Client

initRepository()

Initializes a new Git repository for a project, performs an initial commit, and pushes.

ts
static initRepository(user: string, email: string, workspaceName: string, projectName: string, repositoryName: string, commitMessage: string): void;
ParameterTypeDescription
userstringThe username of the committer.
emailstringThe email address of the committer.
workspaceNamestringThe name of the workspace.
projectNamestringThe name of the project.
repositoryNamestringThe name of the repository (where to put the git folder).
commitMessagestringThe initial commit message.

Returns

  • Type: void
  • Description:

commit()

Performs a commit in the specified repository.

ts
static commit(user: string, email: string, workspaceName: string, repositoryName: string, commitMessage: string, all: boolean): void;
ParameterTypeDescription
userstringThe username of the committer.
emailstringThe email address of the committer.
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
commitMessagestringThe commit message.
allbooleanIf true, automatically stages modified and deleted files before committing.

Returns

  • Type: void
  • Description:

getGitRepositories()

Retrieves a list of all Git repositories (projects) within the specified workspace.

ts
static getGitRepositories(workspaceName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.

Returns

  • Type: void
  • Description: An array of ProjectDescriptor objects.

getHistory()

Retrieves the commit history for the specified repository or a specific file path within it.

ts
static getHistory(repositoryName: string, workspaceName: string, path: string): void;
ParameterTypeDescription
repositoryNamestringThe name of the repository.
workspaceNamestringThe name of the workspace.
pathstringThe file path for history, or null/empty string for full repository history.

Returns

  • Type: void
  • Description: An array of GitCommitInfo objects.

deleteRepository()

Deletes the specified Git repository.

ts
static deleteRepository(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository to delete.

Returns

  • Type: void
  • Description:

cloneRepository()

Clones a remote repository into the local workspace.

ts
static cloneRepository(workspaceName: string, repositoryUri: string, username: string, password: string, branch: string): GitConnector;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryUristringThe URI of the remote repository.
usernamestringThe username for authentication.
passwordstringThe password for authentication.
branchstringThe specific branch to checkout after cloning.

Returns

  • Type: GitConnector
  • Description: A GitConnector instance for interacting directly with the cloned repository.

pull()

Pulls changes from the remote repository and attempts to merge them into the current branch.

ts
static pull(workspaceName: string, repositoryName: string, username: string, password: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
usernamestringThe username for authentication.
passwordstringThe password for authentication.

Returns

  • Type: void
  • Description:

push()

Pushes the local commits to the remote repository.

ts
static push(workspaceName: string, repositoryName: string, username: string, password: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
usernamestringThe username for authentication.
passwordstringThe password for authentication.

Returns

  • Type: void
  • Description:

checkout()

Checks out a specific branch, commit, or tag in the repository.

ts
static checkout(workspaceName: string, repositoryName: string, branch: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe branch or tree-ish object to check out.

Returns

  • Type: void
  • Description:

createBranch()

Creates a new branch starting from a specified point (e.g., HEAD, a commit hash, or another branch).

ts
static createBranch(workspaceName: string, repositoryName: string, branch: string, startingPoint: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe name of the new branch to create.
startingPointstringThe tree-ish object to start the new branch from.

Returns

  • Type: void
  • Description:

deleteBranch()

Deletes a local branch.

ts
static deleteBranch(workspaceName: string, repositoryName: string, branch: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe name of the branch to delete.

Returns

  • Type: void
  • Description:

renameBranch()

Renames a local branch.

ts
static renameBranch(workspaceName: string, repositoryName: string, oldName: string, newName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
oldNamestringThe current name of the branch.
newNamestringThe new name for the branch.

Returns

  • Type: void
  • Description:

createRemoteBranch()

Creates a new remote branch on the Git server.

ts
static createRemoteBranch(workspaceName: string, repositoryName: string, branch: string, startingPoint: string, username: string, password: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe name of the remote branch to create.
startingPointstringThe tree-ish object to start the new remote branch from.
usernamestringThe username for authentication.
passwordstringThe password for authentication.

Returns

  • Type: void
  • Description:

deleteRemoteBranch()

Deletes a remote branch on the Git server.

ts
static deleteRemoteBranch(workspaceName: string, repositoryName: string, branch: string, username: string, password: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe name of the remote branch to delete.
usernamestringThe username for authentication.
passwordstringThe password for authentication.

Returns

  • Type: void
  • Description:

hardReset()

Resets the repository, discarding all uncommitted changes in the working directory and index.

ts
static hardReset(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: void
  • Description:

rebase()

Reapplies commits from the specified branch onto the current branch.

ts
static rebase(workspaceName: string, repositoryName: string, branch: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
branchstringThe branch to rebase.

Returns

  • Type: void
  • Description:

status()

Retrieves the current status of the repository (staged, unstaged, untracked files).

ts
static status(workspaceName: string, repositoryName: string): string;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: string
  • Description: A string representation of the repository status.

getBranch()

Retrieves the name of the currently active branch.

ts
static getBranch(workspaceName: string, repositoryName: string): string;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: string
  • Description: The name of the current branch.

getLocalBranches()

Retrieves a list of all local branches in the repository.

ts
static getLocalBranches(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: void
  • Description: An array of GitBranch objects representing local branches.

getRemoteBranches()

Retrieves a list of all remote branches configured for the repository.

ts
static getRemoteBranches(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: void
  • Description: An array of GitBranch objects representing remote branches.

getUnstagedChanges()

Retrieves a list of all unstaged files (changes not yet added to the index).

ts
static getUnstagedChanges(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: void
  • Description: An array of GitChangedFile objects.

getStagedChanges()

Retrieves a list of all staged files (changes added to the index, ready for commit).

ts
static getStagedChanges(workspaceName: string, repositoryName: string): void;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.

Returns

  • Type: void
  • Description: An array of GitChangedFile objects.

getFileContent()

Retrieves the content of a file at a specific revision (commit, branch, or tag).

ts
static getFileContent(workspaceName: string, repositoryName: string, filePath: string, revStr: string): string;
ParameterTypeDescription
workspaceNamestringThe name of the workspace.
repositoryNamestringThe name of the repository.
filePathstringThe path to the file.
revStrstringThe revision string (e.g., commit hash or branch name).

Returns

  • Type: string
  • Description: The content of the file as a string.