init
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
# API Contract
|
||||
|
||||
The frontend calls Tauri commands with `@tauri-apps/api/core.invoke`.
|
||||
|
||||
## Shared payloads
|
||||
|
||||
```ts
|
||||
type FileStatusKind = "modified" | "added" | "deleted" | "renamed" | "untracked" | "conflicted" | "unknown";
|
||||
|
||||
interface GitStatus {
|
||||
repo_path: string;
|
||||
current_branch: string | null;
|
||||
upstream: string | null;
|
||||
ahead: number;
|
||||
behind: number;
|
||||
files: GitFileStatus[];
|
||||
clean: boolean;
|
||||
}
|
||||
|
||||
interface GitFileStatus {
|
||||
path: string;
|
||||
old_path: string | null;
|
||||
staged: FileStatusKind | null;
|
||||
unstaged: FileStatusKind | null;
|
||||
}
|
||||
|
||||
interface GitBranch {
|
||||
name: string;
|
||||
current: boolean;
|
||||
remote: boolean;
|
||||
}
|
||||
|
||||
interface GitCommit {
|
||||
hash: string;
|
||||
short_hash: string;
|
||||
summary: string;
|
||||
author_name: string;
|
||||
author_email: string;
|
||||
date: string;
|
||||
refs: string[];
|
||||
files: GitCommitFile[];
|
||||
}
|
||||
|
||||
interface GitCommitFile {
|
||||
path: string;
|
||||
old_path: string | null;
|
||||
status: FileStatusKind;
|
||||
}
|
||||
|
||||
interface GitRepositoryFile {
|
||||
path: string;
|
||||
tracked: boolean;
|
||||
status: FileStatusKind | null;
|
||||
}
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
- `open_repository(path: string): Promise<GitStatus>`
|
||||
- `get_status(path: string): Promise<GitStatus>`
|
||||
- `list_branches(path: string): Promise<GitBranch[]>`
|
||||
- `checkout_branch(path: string, branch: string): Promise<GitStatus>`
|
||||
- `stage_files(path: string, files: string[]): Promise<GitStatus>`
|
||||
- `unstage_files(path: string, files: string[]): Promise<GitStatus>`
|
||||
- `restore_files(path: string, files: string[], staged: boolean): Promise<GitStatus>`
|
||||
- `commit(path: string, message: string): Promise<GitStatus>`
|
||||
- `pull(path: string): Promise<GitStatus>`
|
||||
- `push(path: string): Promise<GitStatus>`
|
||||
- `list_commits(path: string, limit?: number): Promise<GitCommit[]>`
|
||||
- `restore_to_commit(path: string, commit: string): Promise<GitStatus>`
|
||||
- `restore_file_from_commit(path: string, commit: string, file: string): Promise<GitStatus>` (the `file` argument can also be a folder path)
|
||||
- `merge_branch(path: string, branch: string): Promise<GitStatus>`
|
||||
- `list_repository_files(path: string): Promise<GitRepositoryFile[]>`
|
||||
- `list_file_history(path: string, file: string, limit?: number): Promise<GitCommit[]>` (the `file` argument can also be a folder path)
|
||||
Reference in New Issue
Block a user