Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
110 lines (106 loc) · 3.23 KB
/
Copy pathtypes.ts
File metadata and controls
110 lines (106 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import type {
CommitMessage,
FileChanges,
} from "./github/graphql/generated/types.ts";
import type { Octokit } from "./github/graphql/queries.ts";
export type GitRef = { branch: string } | { tag: string } | { commit: string };
export interface CommitChangesOptions {
/**
* The Octokit instance to use for making GitHub API requests. Requires APIs
* from `@octokit/core`, `@octokit/plugin-rest-endpoint-methods`, and
* `@octokit/plugin-paginate-rest`.
*/
octokit: Octokit;
/**
* The owner of the repository.
*/
owner: string;
/**
* The name of the repository.
*/
repo: string;
/**
* The name of the branch to commit to.
*/
branch: string;
/**
* The current branch, tag, or commit that the new branch should be based on.
*
* @example
* { branch: "main" }
* @example
* { tag: "v1.0.0" }
* @example
* { commit: "abc123..." }
*/
base: GitRef;
/**
* The files that are added, modified, or deleted in the commit. Added and
* modified files should be in the `additions` array with their content as
* base64-encoded strings. Deleted files should be in the `deletions` array
* with their file paths.
*
* @example
* {
* additions: [{ path: "file.txt", content: "SGVsbG8gd29ybGQ=" }]
* deletions: ["old-file.txt"]
* }
*/
fileChanges: FileChanges;
/**
* The commit message. If a string is passed, the first line will be used as
* the headline, and the rest will be used as the body. An object can also be
* passed to explicitly specify the headline and body.
*/
message: string | CommitMessage;
/**
* If the branch exists but its HEAD does not match the given base, the commit
* cannot be created as their histories have diverged. If this is set to true,
* the commit will be force pushed to the branch instead, overwriting any
* existing commits.
*/
force?: boolean;
}
export interface CommitChangesResult {
/**
* The ref id of the created or update branch.
*/
refId: string;
}
export interface CommitChangesSinceBaseOptions extends Omit<
CommitChangesOptions,
"base" | "fileChanges"
> {
/**
* The base branch, tag, or commit to determine the changes since then. The
* commit form additionally accepts `HEAD` (and similar ref shorthands) instead
* of the full commit SHA.
*
* The default is `{ commit: "HEAD" }`, which includes all uncommitted changes
* since the last commit. If previous commits have been made locally and not
* pushed, you need to set to the last commit that is known to be in the
* remote repository.
*
* If you want to base the changes on a different branch, tag, or commit to
* the one checked out, make sure that you have pulled those refs from the
* remote repository.
*
* @default { commit: "HEAD" }
*/
base?: GitRef;
/**
* The directory to execute git commands in. This can be set if the repository
* is in a different directory.
*
* @default process.cwd()
*/
cwd?: string;
/**
* Filter the files to be included in the commit. The file paths are relative
* to the repository root, e.g. `"src/index.ts"`. Return `true` to include
* the file.
*
* By default, all files are included.
*/
filterFiles?: (file: string) => boolean;
}