git/client
Documentation
- source: git/client.ts
Overview
Classes
Client
initRepository()
Initializes a new Git repository for a project, performs an initial commit, and pushes.
tsstatic initRepository(user: string, email: string, workspaceName: string, projectName: string, repositoryName: string, commitMessage: string): void;
Parameter Type Description userstringThe username of the committer. stringThe 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.
tsstatic commit(user: string, email: string, workspaceName: string, repositoryName: string, commitMessage: string, all: boolean): void;
Parameter Type Description userstringThe username of the committer. stringThe 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.
tsstatic getGitRepositories(workspaceName: string): void;
Parameter Type Description 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.
tsstatic getHistory(repositoryName: string, workspaceName: string, path: string): void;
Parameter Type Description 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.
tsstatic deleteRepository(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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.
tsstatic cloneRepository(workspaceName: string, repositoryUri: string, username: string, password: string, branch: string): GitConnector;
Parameter Type Description 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.
tsstatic pull(workspaceName: string, repositoryName: string, username: string, password: string): void;
Parameter Type Description 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.
tsstatic push(workspaceName: string, repositoryName: string, username: string, password: string): void;
Parameter Type Description 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.
tsstatic checkout(workspaceName: string, repositoryName: string, branch: string): void;
Parameter Type Description 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).
tsstatic createBranch(workspaceName: string, repositoryName: string, branch: string, startingPoint: string): void;
Parameter Type Description 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.
tsstatic deleteBranch(workspaceName: string, repositoryName: string, branch: string): void;
Parameter Type Description 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.
tsstatic renameBranch(workspaceName: string, repositoryName: string, oldName: string, newName: string): void;
Parameter Type Description 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.
tsstatic createRemoteBranch(workspaceName: string, repositoryName: string, branch: string, startingPoint: string, username: string, password: string): void;
Parameter Type Description 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.
tsstatic deleteRemoteBranch(workspaceName: string, repositoryName: string, branch: string, username: string, password: string): void;
Parameter Type Description 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.
tsstatic hardReset(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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.
tsstatic rebase(workspaceName: string, repositoryName: string, branch: string): void;
Parameter Type Description 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).
tsstatic status(workspaceName: string, repositoryName: string): string;
Parameter Type Description 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.
tsstatic getBranch(workspaceName: string, repositoryName: string): string;
Parameter Type Description 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.
tsstatic getLocalBranches(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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.
tsstatic getRemoteBranches(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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).
tsstatic getUnstagedChanges(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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).
tsstatic getStagedChanges(workspaceName: string, repositoryName: string): void;
Parameter Type Description 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).
tsstatic getFileContent(workspaceName: string, repositoryName: string, filePath: string, revStr: string): string;
Parameter Type Description 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.
