@haerphi/vscode-git-api-types
v1.0.2
Published
TypeScript type definitions for the VS Code built-in Git extension API
Readme
@haerphi/vscode-git-api-types
TypeScript type definitions for the VS Code built-in Git extension API.
Installation
npm install @haerphi/vscode-git-api-types
# or
pnpm add @haerphi/vscode-git-api-typesUsage
import type { GitExtension, API, Repository } from '@haerphi/vscode-git-api-types';
const gitExtension = vscode.extensions.getExtension<GitExtension>('vscode.git')!.exports;
const git: API = gitExtension.getAPI(1);Available types
Main entry points
| Type | Description |
|------|-------------|
| GitExtension | Root of the API, retrieved via vscode.extensions.getExtension('vscode.git') |
| API | Main API object returned by GitExtension.getAPI(1) |
| Repository | Represents a Git repository |
Interfaces
| Interface | Description |
|-----------|-------------|
| Git | Exposes the path to the git executable |
| InputBox | The commit message input box |
| Ref | A Git reference (branch, tag, etc.) |
| Branch | A Git branch, extends Ref |
| UpstreamRef | The upstream reference of a branch |
| Commit | A Git commit |
| CommitShortStat | File/insertion/deletion stats for a commit |
| Remote | A Git remote |
| Submodule | A Git submodule |
| Worktree | A Git worktree |
| Change | A file change (staged, unstaged, merge conflict…) |
| DiffChange | A Change with insertion/deletion counts |
| RepositoryState | Full state of a repository (HEAD, refs, remotes, changes…) |
| RepositoryUIState | UI state of a repository (selected in the SCM panel) |
| RepositoryAccessDetails | Root URI and last access time of a repository |
| LogOptions | Options for Repository.log() |
| CommitOptions | Options for Repository.commit() |
| FetchOptions | Options for Repository.fetch() |
| InitOptions | Options for API.init() |
| CloneOptions | Options for API.clone() |
| RefQuery | Query parameters for Repository.getRefs() |
| BranchQuery | Query parameters for Repository.getBranches(), extends RefQuery |
| RemoteSource | A remote source (name, URL) |
| RemoteSourceProvider | Provider for listing remote sources |
| RemoteSourcePublisher | Provider for publishing a repository to a remote |
| Credentials | Username/password credentials |
| CredentialsProvider | Provider for Git credentials |
| PostCommitCommandsProvider | Provider for commands to run after a commit |
| PushErrorHandler | Handler for push errors |
| BranchProtection | Branch protection rules for a remote |
| BranchProtectionRule | Include/exclude patterns for branch protection |
| BranchProtectionProvider | Provider for branch protection rules |
| AvatarQuery | Query for contributor avatars |
| AvatarQueryCommit | Commit info used in an avatar query |
| SourceControlHistoryItemDetailsProvider | Provider for SCM history item details (avatars, hover commands, message links) |
| PublishEvent | Event fired when a repository is published |
Enums
| Enum | Values |
|------|--------|
| RefType | Head, RemoteHead, Tag |
| Status | INDEX_MODIFIED, INDEX_ADDED, INDEX_DELETED, INDEX_RENAMED, INDEX_COPIED, MODIFIED, DELETED, UNTRACKED, IGNORED, INTENT_TO_ADD, INTENT_TO_RENAME, TYPE_CHANGED, ADDED_BY_US, ADDED_BY_THEM, DELETED_BY_US, DELETED_BY_THEM, BOTH_ADDED, BOTH_DELETED, BOTH_MODIFIED |
| ForcePushMode | Force, ForceWithLease, ForceWithLeaseIfIncludes |
| GitErrorCodes | BadConfigFile, BadRevision, AuthenticationFailed, NotAGitRepository, PushRejected, DirtyWorkTree, BranchAlreadyExists, NoStashFound, … (full list in index.d.ts) |
Type aliases
| Alias | Values |
|-------|--------|
| APIState | 'uninitialized' | 'initialized' |
| RepositoryKind | 'repository' | 'submodule' | 'worktree' |
Keeping types up to date
The types are sourced directly from the VS Code repository. To update index.d.ts to the latest version:
npm run update
# optionally, with a GitHub token to avoid rate limiting (60 req/h without token):
GITHUB_TOKEN=ghp_xxx npm run updateThen bump the package version and republish:
npm version patch
npm publish --access publicLicense
MIT
