UNPKG

2.11 kBTypeScriptView Raw
1import { Buf } from './buf';
2import { Repository } from './repository';
3import { WorktreeAddOptions } from './worktree-add-options';
4import { WorktreePruneOptions } from './worktree-prune-options';
5
6export namespace Worktree {
7 const enum PRUNE {
8 VALID = 1,
9 LOCKED = 2,
10 WORKING_TREE = 4,
11 }
12}
13
14export class Worktree {
15 /**
16 * @param repo - Repository to create working tree for
17 * @param name - Name of the working tree
18 * @param path - Path to create working tree at
19 * @param opts - Options to modify default behavior. May be NULL
20 */
21 static add(repo: Repository, name: string, path: string, opts?: WorktreeAddOptions): Promise<Worktree>;
22
23 /**
24 * @param repo - the repo to use when listing working trees
25 */
26 static list(repo: Repository): Promise<string[]>;
27
28 /**
29 * @param repo - The repository containing worktrees
30 * @param name - Name of the working tree to look up
31 */
32 static lookup(repo: Repository, name: string): Promise<Worktree>;
33
34 /**
35 * @param repo - Repository to look up worktree for
36 */
37 static openFromRepository(repo: Repository): Promise<Worktree>;
38
39 /**
40 * @param reason - Buffer to store reason in. If NULL no reason is stored.
41 * @returns - 0 when the working tree not locked, a value greater than zero if it is locked, less than zero if there was an error
42 */
43 isLocked(reason?: Buf): number;
44
45 isPrunable(opts: WorktreePruneOptions): number;
46
47 /**
48 * @param reason - Reason why the working tree is being locked
49 * @returns - 0 on success, non-zero otherwise
50 */
51 lock(reason: string): number;
52
53 name(): string;
54 path(): string;
55
56 /**
57 * @param opts - Specifies which checks to override. See isPrunable. May be NULL
58 * @returns - 0 or an error code
59 */
60 prune(opts?: WorktreePruneOptions): number;
61
62 /**
63 * @returns - 0 on success, 1 if worktree was not locked, error-code
64 */
65 unlock(): number;
66
67 /**
68 * @returns - 0 when worktree is valid, error-code otherwise
69 */
70 validate(): number;
71}