New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@changesets/ghcommit

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@changesets/ghcommit - npm Package Compare versions

Comparing version
1.3.1
to
1.4.0
+112
dist/chunk-SDYEPSTC.mjs
import {
commitFilesFromBuffers
} from "./chunk-UMPES6AZ.mjs";
// src/git.ts
import { promises as fs } from "fs";
import git from "isomorphic-git";
import { isAbsolute, relative } from "path";
var FILE_MODES = {
directory: 16384,
file: 33188,
executableFile: 33261,
symlink: 40960
};
var commitChangesFromRepo = async ({
base,
repoDirectory,
addFromDirectory,
filterFiles,
log,
...otherArgs
}) => {
const ref = base?.commit ?? "HEAD";
const resolvedRepoDirectory = repoDirectory ?? await git.findRoot({ fs, filepath: process.cwd() });
const gitLog = await git.log({
fs,
dir: resolvedRepoDirectory,
ref,
depth: 1
});
const oid = gitLog[0]?.oid;
if (!oid) {
throw new Error(`Could not determine oid for ${ref}`);
}
if (addFromDirectory && !isAbsolute(addFromDirectory)) {
throw new Error(
`addFromDirectory must be an absolute path, got ${addFromDirectory}`
);
}
const relativeStartDirectory = addFromDirectory && relative(resolvedRepoDirectory, addFromDirectory) + "/";
const trees = [git.TREE({ ref: oid }), git.WORKDIR()];
const additions = [];
const deletions = [];
const fileChanges = {
additions,
deletions
};
await git.walk({
fs,
dir: resolvedRepoDirectory,
trees,
map: async (filepath, [commit, workdir]) => {
if (await git.isIgnored({
fs,
dir: resolvedRepoDirectory,
filepath
})) {
return null;
}
if (await commit?.mode() === FILE_MODES.symlink || await workdir?.mode() === FILE_MODES.symlink) {
throw new Error(
`Unexpected symlink at ${filepath}, GitHub API only supports files and directories. You may need to add this file to .gitignore`
);
}
if (await workdir?.mode() === FILE_MODES.executableFile) {
throw new Error(
`Unexpected executable file at ${filepath}, GitHub API only supports non-executable files and directories. You may need to add this file to .gitignore`
);
}
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await commit?.type() === "tree" || await workdir?.type() === "tree") {
return true;
}
if (relativeStartDirectory && !filepath.startsWith(relativeStartDirectory)) {
return null;
}
if (filterFiles && !filterFiles(filepath)) {
return null;
}
if (!workdir) {
deletions.push(filepath);
return null;
} else {
const arr = await workdir.content();
if (!arr) {
throw new Error(`Could not determine content of file ${filepath}`);
}
additions.push({
path: filepath,
contents: Buffer.from(arr)
});
}
return true;
}
});
return commitFilesFromBuffers({
...otherArgs,
fileChanges,
log,
base: {
commit: oid
}
});
};
export {
commitChangesFromRepo
};
type Maybe<T> = T | null;
type InputMaybe<T> = Maybe<T>;
type Exact<T extends {
[key: string]: unknown;
}> = {
[K in keyof T]: T[K];
};
/** All built-in and custom scalars, mapped to their actual values */
type Scalars = {
ID: {
input: string;
output: string;
};
String: {
input: string;
output: string;
};
Boolean: {
input: boolean;
output: boolean;
};
Int: {
input: number;
output: number;
};
Float: {
input: number;
output: number;
};
Base64String: {
input: any;
output: any;
};
BigInt: {
input: any;
output: any;
};
Date: {
input: any;
output: any;
};
DateTime: {
input: any;
output: any;
};
GitObjectID: {
input: any;
output: any;
};
GitSSHRemote: {
input: any;
output: any;
};
GitTimestamp: {
input: any;
output: any;
};
HTML: {
input: any;
output: any;
};
PreciseDateTime: {
input: any;
output: any;
};
URI: {
input: any;
output: any;
};
X509Certificate: {
input: any;
output: any;
};
};
/** A message to include with a new commit */
type CommitMessage = {
/** The body of the message. */
body?: InputMaybe<Scalars['String']['input']>;
/** The headline of the message. */
headline: Scalars['String']['input'];
};
/**
* A git ref for a commit to be appended to.
*
* The ref must be a branch, i.e. its fully qualified name must start
* with `refs/heads/` (although the input is not required to be fully
* qualified).
*
* The Ref may be specified by its global node ID or by the
* `repositoryNameWithOwner` and `branchName`.
*
* ### Examples
*
* Specify a branch using a global node ID:
*
* { "id": "MDM6UmVmMTpyZWZzL2hlYWRzL21haW4=" }
*
* Specify a branch using `repositoryNameWithOwner` and `branchName`:
*
* {
* "repositoryNameWithOwner": "github/graphql-client",
* "branchName": "main"
* }
*
*
*/
type CommittableBranch = {
/** The unqualified name of the branch to append the commit to. */
branchName?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be updated. */
id?: InputMaybe<Scalars['ID']['input']>;
/** The nameWithOwner of the repository to commit to. */
repositoryNameWithOwner?: InputMaybe<Scalars['String']['input']>;
};
/** Autogenerated input type of CreateCommitOnBranch */
type CreateCommitOnBranchInput = {
/** The Ref to be updated. Must be a branch. */
branch: CommittableBranch;
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The git commit oid expected at the head of the branch prior to the commit */
expectedHeadOid: Scalars['GitObjectID']['input'];
/** A description of changes to files in this commit. */
fileChanges?: InputMaybe<FileChanges>;
/** The commit message the be included with the commit. */
message: CommitMessage;
};
/** Autogenerated input type of CreateRef */
type CreateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The fully qualified name of the new Ref (ie: `refs/heads/my_new_branch`). */
name: Scalars['String']['input'];
/** The GitObjectID that the new Ref shall target. Must point to a commit. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Repository to create the Ref in. */
repositoryId: Scalars['ID']['input'];
};
/** Autogenerated input type of DeleteRef */
type DeleteRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be deleted. */
refId: Scalars['ID']['input'];
};
/** A command to add a file at the given path with the given contents as part of a commit. Any existing file at that that path will be replaced. */
type FileAddition = {
/** The base64 encoded contents of the file */
contents: Scalars['Base64String']['input'];
/** The path in the repository where the file will be located */
path: Scalars['String']['input'];
};
/**
* A description of a set of changes to a file tree to be made as part of
* a git commit, modeled as zero or more file `additions` and zero or more
* file `deletions`.
*
* Both fields are optional; omitting both will produce a commit with no
* file changes.
*
* `deletions` and `additions` describe changes to files identified
* by their path in the git tree using unix-style path separators, i.e.
* `/`. The root of a git tree is an empty string, so paths are not
* slash-prefixed.
*
* `path` values must be unique across all `additions` and `deletions`
* provided. Any duplication will result in a validation error.
*
* ### Encoding
*
* File contents must be provided in full for each `FileAddition`.
*
* The `contents` of a `FileAddition` must be encoded using RFC 4648
* compliant base64, i.e. correct padding is required and no characters
* outside the standard alphabet may be used. Invalid base64
* encoding will be rejected with a validation error.
*
* The encoded contents may be binary.
*
* For text files, no assumptions are made about the character encoding of
* the file contents (after base64 decoding). No charset transcoding or
* line-ending normalization will be performed; it is the client's
* responsibility to manage the character encoding of files they provide.
* However, for maximum compatibility we recommend using UTF-8 encoding
* and ensuring that all files in a repository use a consistent
* line-ending convention (`\n` or `\r\n`), and that all files end
* with a newline.
*
* ### Modeling file changes
*
* Each of the the five types of conceptual changes that can be made in a
* git commit can be described using the `FileChanges` type as follows:
*
* 1. New file addition: create file `hello world\n` at path `docs/README.txt`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
* 2. Existing file modification: change existing `docs/README.txt` to have new
* content `new content here\n`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("new content here\n")
* }
* ]
* }
*
* 3. Existing file deletion: remove existing file `docs/README.txt`.
* Note that the path is required to exist -- specifying a
* path that does not exist on the given branch will abort the
* commit and return an error.
*
* {
* "deletions" [
* {
* "path": "docs/README.txt"
* }
* ]
* }
*
*
* 4. File rename with no changes: rename `docs/README.txt` with
* previous content `hello world\n` to the same content at
* `newdocs/README.txt`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
*
* 5. File rename with changes: rename `docs/README.txt` with
* previous content `hello world\n` to a file at path
* `newdocs/README.txt` with content `new contents\n`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("new contents\n")
* }
* ]
* }
*
*/
type FileChanges = {
/** File to add or change. */
additions?: InputMaybe<Array<FileAddition>>;
/** Files to delete. */
deletions?: InputMaybe<Array<FileDeletion>>;
};
/** A command to delete the file at the given path as part of a commit. */
type FileDeletion = {
/** The path to delete */
path: Scalars['String']['input'];
};
/** Autogenerated input type of UpdateRef */
type UpdateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** Permit updates of branch Refs that are not fast-forwards? */
force?: InputMaybe<Scalars['Boolean']['input']>;
/** The GitObjectID that the Ref shall be updated to target. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Ref to be updated. */
refId: Scalars['ID']['input'];
};
type GetRepositoryMetadataQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
baseRef: Scalars['String']['input'];
targetRef: Scalars['String']['input'];
}>;
type GetRepositoryMetadataQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
id: string;
baseRef?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
target: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
};
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
targetBranch?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
} | null;
};
type CreateRefMutationVariables = Exact<{
input: CreateRefInput;
}>;
type CreateRefMutation = {
__typename?: 'Mutation';
createRef?: {
__typename?: 'CreateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type UpdateRefMutationVariables = Exact<{
input: UpdateRefInput;
}>;
type UpdateRefMutation = {
__typename?: 'Mutation';
updateRef?: {
__typename?: 'UpdateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type DeleteRefMutationVariables = Exact<{
input: DeleteRefInput;
}>;
type DeleteRefMutation = {
__typename?: 'Mutation';
deleteRef?: {
__typename?: 'DeleteRefPayload';
clientMutationId?: string | null;
} | null;
};
type CreateCommitOnBranchMutationVariables = Exact<{
input: CreateCommitOnBranchInput;
}>;
type CreateCommitOnBranchMutation = {
__typename?: 'Mutation';
createCommitOnBranch?: {
__typename?: 'CreateCommitOnBranchPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type GetRefTreeQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
ref: Scalars['String']['input'];
path: Scalars['String']['input'];
}>;
type GetRefTreeQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
ref?: {
__typename?: 'Ref';
target?: {
__typename?: 'Blob';
} | {
__typename?: 'Commit';
message: string;
tree: {
__typename?: 'Tree';
oid: any;
};
parents: {
__typename?: 'CommitConnection';
nodes?: Array<{
__typename?: 'Commit';
oid: any;
} | null> | null;
};
file?: {
__typename?: 'TreeEntry';
oid: any;
} | null;
} | {
__typename?: 'Tag';
} | {
__typename?: 'Tree';
} | null;
} | null;
} | null;
};
type GitHubClient = {
graphql: <T>(query: string, variables: any) => Promise<T>;
};
declare const getRepositoryMetadata: (o: GitHubClient, v: GetRepositoryMetadataQueryVariables) => Promise<GetRepositoryMetadataQuery["repository"]>;
declare const createRefMutation: (o: GitHubClient, v: CreateRefMutationVariables) => Promise<CreateRefMutation>;
declare const updateRefMutation: (o: GitHubClient, v: UpdateRefMutationVariables) => Promise<UpdateRefMutation>;
declare const deleteRefMutation: (o: GitHubClient, v: DeleteRefMutationVariables) => Promise<DeleteRefMutation>;
declare const createCommitOnBranchQuery: (o: GitHubClient, v: CreateCommitOnBranchMutationVariables) => Promise<CreateCommitOnBranchMutation>;
declare const getRefTreeQuery: (o: GitHubClient, v: GetRefTreeQueryVariables) => Promise<GetRefTreeQuery>;
type queries_GitHubClient = GitHubClient;
declare const queries_createCommitOnBranchQuery: typeof createCommitOnBranchQuery;
declare const queries_createRefMutation: typeof createRefMutation;
declare const queries_deleteRefMutation: typeof deleteRefMutation;
declare const queries_getRefTreeQuery: typeof getRefTreeQuery;
declare const queries_getRepositoryMetadata: typeof getRepositoryMetadata;
declare const queries_updateRefMutation: typeof updateRefMutation;
declare namespace queries {
export { type queries_GitHubClient as GitHubClient, queries_createCommitOnBranchQuery as createCommitOnBranchQuery, queries_createRefMutation as createRefMutation, queries_deleteRefMutation as deleteRefMutation, queries_getRefTreeQuery as getRefTreeQuery, queries_getRepositoryMetadata as getRepositoryMetadata, queries_updateRefMutation as updateRefMutation };
}
interface Logger {
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
debug(msg: string): void;
}
type CommitFilesResult = {
refId: string | null;
};
type GitBase = {
branch: string;
} | {
tag: string;
} | {
commit: string;
};
interface CommitFilesBasedArgs {
octokit: GitHubClient;
owner: string;
repo?: string;
/** @deprecated use {@link repo} instead */
repository?: string;
branch: string;
/**
* Push the commit even if the branch exists and does not match what was
* specified as the base.
*/
force?: boolean;
/**
* The commit message
*/
message: string | CommitMessage;
log?: Logger;
}
interface CommitFilesSharedArgsWithBase extends CommitFilesBasedArgs {
/**
* The current branch, tag or commit that the new branch should be based on.
*/
base: GitBase;
}
interface CommitFilesFromBase64Args extends CommitFilesSharedArgsWithBase {
fileChanges: FileChanges;
}
interface CommitFilesFromBuffersArgs extends CommitFilesSharedArgsWithBase {
/**
* The file changes, relative to the repository root, to make to the specified branch.
*/
fileChanges: {
additions?: Array<{
path: string;
contents: Buffer;
}>;
deletions?: string[];
};
}
interface CommitFilesFromDirectoryArgs extends CommitFilesSharedArgsWithBase {
/**
* The directory to consider the root of the repository when calculating
* file paths
*/
workingDirectory?: string;
/**
* The file paths, relative to {@link workingDirectory},
* to add or delete from the branch on GitHub.
*/
fileChanges: {
/** File paths, relative to {@link workingDirectory}, to remove from the repo. */
additions?: string[];
/** File paths, relative to the repository root, to remove from the repo. */
deletions?: string[];
};
}
interface CommitChangesFromRepoArgs extends CommitFilesBasedArgs {
/**
* The base commit to build your changes on-top of.
*
* By default, this commit will be the HEAD of the local repository,
* meaning that if any commits have been made locally and not pushed,
* this command will fail.
*
* To include all changes, this should be set to a commit that is known
* to be in the remote repository (such as the default branch).
*
* If you want to base the changes on a different commit to one checked out,
* make sure that you also pull this commit from the remote.
*
* @default HEAD
*/
base?: {
commit: string;
};
/**
* The root of the repository.
*
* When unspecified, the root of the repository will be found by recursively
* searching for the `.git` directory from the current working directory.
*/
repoDirectory?: string;
/**
* The starting directory to recurse from when detecting changed files.
*
* Useful for monorepos where you want to add files from a specific directory only.
*
* Defaults to resolved value of {@link repoDirectory},
* which will add all changed files in the repository.
*/
addFromDirectory?: string;
/**
* An optional function that can be used to filter which files are included
* in the commit. True should be returned for files that should be included.
*
* By default, all files are included.
*/
filterFiles?: (file: string) => boolean;
}
export { type CommitFilesFromBase64Args as C, type CommitFilesResult as a, type CommitFilesFromDirectoryArgs as b, type CommitChangesFromRepoArgs as c, type CommitFilesFromBuffersArgs as d, queries as q };
type Maybe<T> = T | null;
type InputMaybe<T> = Maybe<T>;
type Exact<T extends {
[key: string]: unknown;
}> = {
[K in keyof T]: T[K];
};
/** All built-in and custom scalars, mapped to their actual values */
type Scalars = {
ID: {
input: string;
output: string;
};
String: {
input: string;
output: string;
};
Boolean: {
input: boolean;
output: boolean;
};
Int: {
input: number;
output: number;
};
Float: {
input: number;
output: number;
};
Base64String: {
input: any;
output: any;
};
BigInt: {
input: any;
output: any;
};
Date: {
input: any;
output: any;
};
DateTime: {
input: any;
output: any;
};
GitObjectID: {
input: any;
output: any;
};
GitSSHRemote: {
input: any;
output: any;
};
GitTimestamp: {
input: any;
output: any;
};
HTML: {
input: any;
output: any;
};
PreciseDateTime: {
input: any;
output: any;
};
URI: {
input: any;
output: any;
};
X509Certificate: {
input: any;
output: any;
};
};
/** A message to include with a new commit */
type CommitMessage = {
/** The body of the message. */
body?: InputMaybe<Scalars['String']['input']>;
/** The headline of the message. */
headline: Scalars['String']['input'];
};
/**
* A git ref for a commit to be appended to.
*
* The ref must be a branch, i.e. its fully qualified name must start
* with `refs/heads/` (although the input is not required to be fully
* qualified).
*
* The Ref may be specified by its global node ID or by the
* `repositoryNameWithOwner` and `branchName`.
*
* ### Examples
*
* Specify a branch using a global node ID:
*
* { "id": "MDM6UmVmMTpyZWZzL2hlYWRzL21haW4=" }
*
* Specify a branch using `repositoryNameWithOwner` and `branchName`:
*
* {
* "repositoryNameWithOwner": "github/graphql-client",
* "branchName": "main"
* }
*
*
*/
type CommittableBranch = {
/** The unqualified name of the branch to append the commit to. */
branchName?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be updated. */
id?: InputMaybe<Scalars['ID']['input']>;
/** The nameWithOwner of the repository to commit to. */
repositoryNameWithOwner?: InputMaybe<Scalars['String']['input']>;
};
/** Autogenerated input type of CreateCommitOnBranch */
type CreateCommitOnBranchInput = {
/** The Ref to be updated. Must be a branch. */
branch: CommittableBranch;
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The git commit oid expected at the head of the branch prior to the commit */
expectedHeadOid: Scalars['GitObjectID']['input'];
/** A description of changes to files in this commit. */
fileChanges?: InputMaybe<FileChanges>;
/** The commit message the be included with the commit. */
message: CommitMessage;
};
/** Autogenerated input type of CreateRef */
type CreateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The fully qualified name of the new Ref (ie: `refs/heads/my_new_branch`). */
name: Scalars['String']['input'];
/** The GitObjectID that the new Ref shall target. Must point to a commit. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Repository to create the Ref in. */
repositoryId: Scalars['ID']['input'];
};
/** Autogenerated input type of DeleteRef */
type DeleteRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be deleted. */
refId: Scalars['ID']['input'];
};
/** A command to add a file at the given path with the given contents as part of a commit. Any existing file at that that path will be replaced. */
type FileAddition = {
/** The base64 encoded contents of the file */
contents: Scalars['Base64String']['input'];
/** The path in the repository where the file will be located */
path: Scalars['String']['input'];
};
/**
* A description of a set of changes to a file tree to be made as part of
* a git commit, modeled as zero or more file `additions` and zero or more
* file `deletions`.
*
* Both fields are optional; omitting both will produce a commit with no
* file changes.
*
* `deletions` and `additions` describe changes to files identified
* by their path in the git tree using unix-style path separators, i.e.
* `/`. The root of a git tree is an empty string, so paths are not
* slash-prefixed.
*
* `path` values must be unique across all `additions` and `deletions`
* provided. Any duplication will result in a validation error.
*
* ### Encoding
*
* File contents must be provided in full for each `FileAddition`.
*
* The `contents` of a `FileAddition` must be encoded using RFC 4648
* compliant base64, i.e. correct padding is required and no characters
* outside the standard alphabet may be used. Invalid base64
* encoding will be rejected with a validation error.
*
* The encoded contents may be binary.
*
* For text files, no assumptions are made about the character encoding of
* the file contents (after base64 decoding). No charset transcoding or
* line-ending normalization will be performed; it is the client's
* responsibility to manage the character encoding of files they provide.
* However, for maximum compatibility we recommend using UTF-8 encoding
* and ensuring that all files in a repository use a consistent
* line-ending convention (`\n` or `\r\n`), and that all files end
* with a newline.
*
* ### Modeling file changes
*
* Each of the the five types of conceptual changes that can be made in a
* git commit can be described using the `FileChanges` type as follows:
*
* 1. New file addition: create file `hello world\n` at path `docs/README.txt`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
* 2. Existing file modification: change existing `docs/README.txt` to have new
* content `new content here\n`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("new content here\n")
* }
* ]
* }
*
* 3. Existing file deletion: remove existing file `docs/README.txt`.
* Note that the path is required to exist -- specifying a
* path that does not exist on the given branch will abort the
* commit and return an error.
*
* {
* "deletions" [
* {
* "path": "docs/README.txt"
* }
* ]
* }
*
*
* 4. File rename with no changes: rename `docs/README.txt` with
* previous content `hello world\n` to the same content at
* `newdocs/README.txt`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
*
* 5. File rename with changes: rename `docs/README.txt` with
* previous content `hello world\n` to a file at path
* `newdocs/README.txt` with content `new contents\n`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("new contents\n")
* }
* ]
* }
*
*/
type FileChanges = {
/** File to add or change. */
additions?: InputMaybe<Array<FileAddition>>;
/** Files to delete. */
deletions?: InputMaybe<Array<FileDeletion>>;
};
/** A command to delete the file at the given path as part of a commit. */
type FileDeletion = {
/** The path to delete */
path: Scalars['String']['input'];
};
/** Autogenerated input type of UpdateRef */
type UpdateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** Permit updates of branch Refs that are not fast-forwards? */
force?: InputMaybe<Scalars['Boolean']['input']>;
/** The GitObjectID that the Ref shall be updated to target. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Ref to be updated. */
refId: Scalars['ID']['input'];
};
type GetRepositoryMetadataQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
baseRef: Scalars['String']['input'];
targetRef: Scalars['String']['input'];
}>;
type GetRepositoryMetadataQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
id: string;
baseRef?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
target: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
};
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
targetBranch?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
} | null;
};
type CreateRefMutationVariables = Exact<{
input: CreateRefInput;
}>;
type CreateRefMutation = {
__typename?: 'Mutation';
createRef?: {
__typename?: 'CreateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type UpdateRefMutationVariables = Exact<{
input: UpdateRefInput;
}>;
type UpdateRefMutation = {
__typename?: 'Mutation';
updateRef?: {
__typename?: 'UpdateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type DeleteRefMutationVariables = Exact<{
input: DeleteRefInput;
}>;
type DeleteRefMutation = {
__typename?: 'Mutation';
deleteRef?: {
__typename?: 'DeleteRefPayload';
clientMutationId?: string | null;
} | null;
};
type CreateCommitOnBranchMutationVariables = Exact<{
input: CreateCommitOnBranchInput;
}>;
type CreateCommitOnBranchMutation = {
__typename?: 'Mutation';
createCommitOnBranch?: {
__typename?: 'CreateCommitOnBranchPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type GetRefTreeQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
ref: Scalars['String']['input'];
path: Scalars['String']['input'];
}>;
type GetRefTreeQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
ref?: {
__typename?: 'Ref';
target?: {
__typename?: 'Blob';
} | {
__typename?: 'Commit';
message: string;
tree: {
__typename?: 'Tree';
oid: any;
};
parents: {
__typename?: 'CommitConnection';
nodes?: Array<{
__typename?: 'Commit';
oid: any;
} | null> | null;
};
file?: {
__typename?: 'TreeEntry';
oid: any;
} | null;
} | {
__typename?: 'Tag';
} | {
__typename?: 'Tree';
} | null;
} | null;
} | null;
};
type GitHubClient = {
graphql: <T>(query: string, variables: any) => Promise<T>;
};
declare const getRepositoryMetadata: (o: GitHubClient, v: GetRepositoryMetadataQueryVariables) => Promise<GetRepositoryMetadataQuery["repository"]>;
declare const createRefMutation: (o: GitHubClient, v: CreateRefMutationVariables) => Promise<CreateRefMutation>;
declare const updateRefMutation: (o: GitHubClient, v: UpdateRefMutationVariables) => Promise<UpdateRefMutation>;
declare const deleteRefMutation: (o: GitHubClient, v: DeleteRefMutationVariables) => Promise<DeleteRefMutation>;
declare const createCommitOnBranchQuery: (o: GitHubClient, v: CreateCommitOnBranchMutationVariables) => Promise<CreateCommitOnBranchMutation>;
declare const getRefTreeQuery: (o: GitHubClient, v: GetRefTreeQueryVariables) => Promise<GetRefTreeQuery>;
type queries_GitHubClient = GitHubClient;
declare const queries_createCommitOnBranchQuery: typeof createCommitOnBranchQuery;
declare const queries_createRefMutation: typeof createRefMutation;
declare const queries_deleteRefMutation: typeof deleteRefMutation;
declare const queries_getRefTreeQuery: typeof getRefTreeQuery;
declare const queries_getRepositoryMetadata: typeof getRepositoryMetadata;
declare const queries_updateRefMutation: typeof updateRefMutation;
declare namespace queries {
export { type queries_GitHubClient as GitHubClient, queries_createCommitOnBranchQuery as createCommitOnBranchQuery, queries_createRefMutation as createRefMutation, queries_deleteRefMutation as deleteRefMutation, queries_getRefTreeQuery as getRefTreeQuery, queries_getRepositoryMetadata as getRepositoryMetadata, queries_updateRefMutation as updateRefMutation };
}
interface Logger {
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
debug(msg: string): void;
}
type CommitFilesResult = {
refId: string | null;
};
type GitBase = {
branch: string;
} | {
tag: string;
} | {
commit: string;
};
interface CommitFilesBasedArgs {
octokit: GitHubClient;
owner: string;
repo?: string;
/** @deprecated use {@link repo} instead */
repository?: string;
branch: string;
/**
* Push the commit even if the branch exists and does not match what was
* specified as the base.
*/
force?: boolean;
/**
* The commit message
*/
message: string | CommitMessage;
log?: Logger;
}
interface CommitFilesSharedArgsWithBase extends CommitFilesBasedArgs {
/**
* The current branch, tag or commit that the new branch should be based on.
*/
base: GitBase;
}
interface CommitFilesFromBase64Args extends CommitFilesSharedArgsWithBase {
fileChanges: FileChanges;
}
interface CommitFilesFromBuffersArgs extends CommitFilesSharedArgsWithBase {
/**
* The file changes, relative to the repository root, to make to the specified branch.
*/
fileChanges: {
additions?: Array<{
path: string;
contents: Buffer;
}>;
deletions?: string[];
};
}
interface CommitFilesFromDirectoryArgs extends CommitFilesSharedArgsWithBase {
/**
* The directory to consider the root of the repository when calculating
* file paths
*/
workingDirectory?: string;
/**
* The file paths, relative to {@link workingDirectory},
* to add or delete from the branch on GitHub.
*/
fileChanges: {
/** File paths, relative to {@link workingDirectory}, to remove from the repo. */
additions?: string[];
/** File paths, relative to the repository root, to remove from the repo. */
deletions?: string[];
};
}
interface CommitChangesFromRepoArgs extends CommitFilesBasedArgs {
/**
* The base commit to build your changes on-top of.
*
* By default, this commit will be the HEAD of the local repository,
* meaning that if any commits have been made locally and not pushed,
* this command will fail.
*
* To include all changes, this should be set to a commit that is known
* to be in the remote repository (such as the default branch).
*
* If you want to base the changes on a different commit to one checked out,
* make sure that you also pull this commit from the remote.
*
* @default HEAD
*/
base?: {
commit: string;
};
/**
* The root of the repository.
*
* When unspecified, the root of the repository will be found by recursively
* searching for the `.git` directory from the current working directory.
*/
repoDirectory?: string;
/**
* The starting directory to recurse from when detecting changed files.
*
* Useful for monorepos where you want to add files from a specific directory only.
*
* Defaults to resolved value of {@link repoDirectory},
* which will add all changed files in the repository.
*/
addFromDirectory?: string;
/**
* An optional function that can be used to filter which files are included
* in the commit. True should be returned for files that should be included.
*
* By default, all files are included.
*/
filterFiles?: (file: string) => boolean;
}
export { type CommitFilesFromBase64Args as C, type CommitFilesResult as a, type CommitFilesFromDirectoryArgs as b, type CommitChangesFromRepoArgs as c, type CommitFilesFromBuffersArgs as d, queries as q };
+1
-1

@@ -1,2 +0,2 @@

import { C as CommitFilesFromBase64Args, a as CommitFilesResult } from './interface-CSlSbqMF.mjs';
import { C as CommitFilesFromBase64Args, a as CommitFilesResult } from './interface-xXQdq6Jm.mjs';

@@ -3,0 +3,0 @@ declare const commitFilesFromBase64: ({ octokit, owner, repo, repository, branch, base, force, message, fileChanges, log, }: CommitFilesFromBase64Args) => Promise<CommitFilesResult>;

@@ -1,2 +0,2 @@

import { C as CommitFilesFromBase64Args, a as CommitFilesResult } from './interface-CSlSbqMF.js';
import { C as CommitFilesFromBase64Args, a as CommitFilesResult } from './interface-xXQdq6Jm.js';

@@ -3,0 +3,0 @@ declare const commitFilesFromBase64: ({ octokit, owner, repo, repository, branch, base, force, message, fileChanges, log, }: CommitFilesFromBase64Args) => Promise<CommitFilesResult>;

@@ -1,2 +0,2 @@

import { b as CommitFilesFromDirectoryArgs, a as CommitFilesResult } from './interface-CSlSbqMF.mjs';
import { b as CommitFilesFromDirectoryArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.mjs';

@@ -3,0 +3,0 @@ declare const commitFilesFromDirectory: ({ workingDirectory, fileChanges, ...otherArgs }: CommitFilesFromDirectoryArgs) => Promise<CommitFilesResult>;

@@ -1,2 +0,2 @@

import { b as CommitFilesFromDirectoryArgs, a as CommitFilesResult } from './interface-CSlSbqMF.js';
import { b as CommitFilesFromDirectoryArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.js';

@@ -3,0 +3,0 @@ declare const commitFilesFromDirectory: ({ workingDirectory, fileChanges, ...otherArgs }: CommitFilesFromDirectoryArgs) => Promise<CommitFilesResult>;

@@ -1,5 +0,5 @@

import { c as CommitChangesFromRepoArgs, a as CommitFilesResult } from './interface-CSlSbqMF.mjs';
import { c as CommitChangesFromRepoArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.mjs';
declare const commitChangesFromRepo: ({ base, repoDirectory, log, ...otherArgs }: CommitChangesFromRepoArgs) => Promise<CommitFilesResult>;
declare const commitChangesFromRepo: ({ base, repoDirectory, addFromDirectory, filterFiles, log, ...otherArgs }: CommitChangesFromRepoArgs) => Promise<CommitFilesResult>;
export { commitChangesFromRepo };

@@ -1,5 +0,5 @@

import { c as CommitChangesFromRepoArgs, a as CommitFilesResult } from './interface-CSlSbqMF.js';
import { c as CommitChangesFromRepoArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.js';
declare const commitChangesFromRepo: ({ base, repoDirectory, log, ...otherArgs }: CommitChangesFromRepoArgs) => Promise<CommitFilesResult>;
declare const commitChangesFromRepo: ({ base, repoDirectory, addFromDirectory, filterFiles, log, ...otherArgs }: CommitChangesFromRepoArgs) => Promise<CommitFilesResult>;
export { commitChangesFromRepo };

@@ -272,5 +272,14 @@ "use strict";

// src/git.ts
var import_path = require("path");
var FILE_MODES = {
directory: 16384,
file: 33188,
executableFile: 33261,
symlink: 40960
};
var commitChangesFromRepo = async ({
base,
repoDirectory = process.cwd(),
repoDirectory,
addFromDirectory,
filterFiles,
log,

@@ -280,5 +289,6 @@ ...otherArgs

const ref = base?.commit ?? "HEAD";
const resolvedRepoDirectory = repoDirectory ?? await import_isomorphic_git.default.findRoot({ fs: import_fs.promises, filepath: process.cwd() });
const gitLog = await import_isomorphic_git.default.log({
fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
ref,

@@ -291,2 +301,8 @@ depth: 1

}
if (addFromDirectory && !(0, import_path.isAbsolute)(addFromDirectory)) {
throw new Error(
`addFromDirectory must be an absolute path, got ${addFromDirectory}`
);
}
const relativeStartDirectory = addFromDirectory && (0, import_path.relative)(resolvedRepoDirectory, addFromDirectory) + "/";
const trees = [import_isomorphic_git.default.TREE({ ref: oid }), import_isomorphic_git.default.WORKDIR()];

@@ -301,13 +317,8 @@ const additions = [];

fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
trees,
map: async (filepath, [commit, workdir]) => {
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await import_isomorphic_git.default.isIgnored({
fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
filepath

@@ -317,5 +328,26 @@ })) {

}
if (await commit?.mode() === FILE_MODES.symlink || await workdir?.mode() === FILE_MODES.symlink) {
throw new Error(
`Unexpected symlink at ${filepath}, GitHub API only supports files and directories. You may need to add this file to .gitignore`
);
}
if (await workdir?.mode() === FILE_MODES.executableFile) {
throw new Error(
`Unexpected executable file at ${filepath}, GitHub API only supports non-executable files and directories. You may need to add this file to .gitignore`
);
}
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await commit?.type() === "tree" || await workdir?.type() === "tree") {
return true;
}
if (relativeStartDirectory && !filepath.startsWith(relativeStartDirectory)) {
return null;
}
if (filterFiles && !filterFiles(filepath)) {
return null;
}
if (!workdir) {

@@ -322,0 +354,0 @@ deletions.push(filepath);

import {
commitChangesFromRepo
} from "./chunk-BN43Q2NX.mjs";
} from "./chunk-SDYEPSTC.mjs";
import "./chunk-UMPES6AZ.mjs";

@@ -5,0 +5,0 @@ import "./chunk-FDFAU3GI.mjs";

@@ -1,4 +0,4 @@

export { q as queries } from './interface-CSlSbqMF.mjs';
export { q as queries } from './interface-xXQdq6Jm.mjs';
export { commitFilesFromBase64 } from './core.mjs';
export { commitChangesFromRepo } from './git.mjs';
export { commitFilesFromDirectory } from './fs.mjs';

@@ -1,4 +0,4 @@

export { q as queries } from './interface-CSlSbqMF.js';
export { q as queries } from './interface-xXQdq6Jm.js';
export { commitFilesFromBase64 } from './core.js';
export { commitChangesFromRepo } from './git.js';
export { commitFilesFromDirectory } from './fs.js';

@@ -330,5 +330,14 @@ "use strict";

// src/git.ts
var import_path = require("path");
var FILE_MODES = {
directory: 16384,
file: 33188,
executableFile: 33261,
symlink: 40960
};
var commitChangesFromRepo = async ({
base,
repoDirectory = process.cwd(),
repoDirectory,
addFromDirectory,
filterFiles,
log,

@@ -338,5 +347,6 @@ ...otherArgs

const ref = base?.commit ?? "HEAD";
const resolvedRepoDirectory = repoDirectory ?? await import_isomorphic_git.default.findRoot({ fs: import_fs.promises, filepath: process.cwd() });
const gitLog = await import_isomorphic_git.default.log({
fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
ref,

@@ -349,2 +359,8 @@ depth: 1

}
if (addFromDirectory && !(0, import_path.isAbsolute)(addFromDirectory)) {
throw new Error(
`addFromDirectory must be an absolute path, got ${addFromDirectory}`
);
}
const relativeStartDirectory = addFromDirectory && (0, import_path.relative)(resolvedRepoDirectory, addFromDirectory) + "/";
const trees = [import_isomorphic_git.default.TREE({ ref: oid }), import_isomorphic_git.default.WORKDIR()];

@@ -359,13 +375,8 @@ const additions = [];

fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
trees,
map: async (filepath, [commit, workdir]) => {
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await import_isomorphic_git.default.isIgnored({
fs: import_fs.promises,
dir: repoDirectory,
dir: resolvedRepoDirectory,
filepath

@@ -375,5 +386,26 @@ })) {

}
if (await commit?.mode() === FILE_MODES.symlink || await workdir?.mode() === FILE_MODES.symlink) {
throw new Error(
`Unexpected symlink at ${filepath}, GitHub API only supports files and directories. You may need to add this file to .gitignore`
);
}
if (await workdir?.mode() === FILE_MODES.executableFile) {
throw new Error(
`Unexpected executable file at ${filepath}, GitHub API only supports non-executable files and directories. You may need to add this file to .gitignore`
);
}
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await commit?.type() === "tree" || await workdir?.type() === "tree") {
return true;
}
if (relativeStartDirectory && !filepath.startsWith(relativeStartDirectory)) {
return null;
}
if (filterFiles && !filterFiles(filepath)) {
return null;
}
if (!workdir) {

@@ -380,0 +412,0 @@ deletions.push(filepath);

@@ -6,3 +6,3 @@ import {

commitChangesFromRepo
} from "./chunk-BN43Q2NX.mjs";
} from "./chunk-SDYEPSTC.mjs";
import "./chunk-UMPES6AZ.mjs";

@@ -9,0 +9,0 @@ import {

@@ -1,2 +0,2 @@

import { d as CommitFilesFromBuffersArgs, a as CommitFilesResult } from './interface-CSlSbqMF.mjs';
import { d as CommitFilesFromBuffersArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.mjs';

@@ -3,0 +3,0 @@ declare const commitFilesFromBuffers: ({ fileChanges, ...otherArgs }: CommitFilesFromBuffersArgs) => Promise<CommitFilesResult>;

@@ -1,2 +0,2 @@

import { d as CommitFilesFromBuffersArgs, a as CommitFilesResult } from './interface-CSlSbqMF.js';
import { d as CommitFilesFromBuffersArgs, a as CommitFilesResult } from './interface-xXQdq6Jm.js';

@@ -3,0 +3,0 @@ declare const commitFilesFromBuffers: ({ fileChanges, ...otherArgs }: CommitFilesFromBuffersArgs) => Promise<CommitFilesResult>;

{
"name": "@changesets/ghcommit",
"version": "1.3.1",
"version": "1.4.0",
"description": "Directly change files on github using the github API, to support GPG signing",

@@ -49,4 +49,4 @@ "keywords": [

"@actions/github": "^6.0.0",
"@changesets/changelog-github": "^0.5.1",
"@changesets/cli": "^2.27.7",
"@changesets/changelog-github": "^0.5.1",
"@graphql-codegen/cli": "^5.0.2",

@@ -70,2 +70,3 @@ "@graphql-codegen/import-types-preset": "^3.0.0",

"jest": "^29.7.0",
"mock-cwd": "^1.0.0",
"pino": "^9.3.2",

@@ -72,0 +73,0 @@ "pino-pretty": "^11.2.2",

@@ -96,5 +96,22 @@ # `@changesets/ghcommit`

*
* @default process.cwd()
* When unspecified, the root of the repository will be found by recursively
* searching for the `.git` directory from the current working directory.
*/
repoDirectory?: string;
/**
* The starting directory to recurse from when detecting changed files.
*
* Useful for monorepos where you want to add files from a specific directory only.
*
* Defaults to resolved value of {@link repoDirectory},
* which will add all changed files in the repository.
*/
addFromDirectory?: string;
/**
* An optional function that can be used to filter which files are included
* in the commit. True should be returned for files that should be included.
*
* By default, all files are included.
*/
filterFiles?: (file: string) => boolean;
}

@@ -101,0 +118,0 @@ ```

import {
commitFilesFromBuffers
} from "./chunk-UMPES6AZ.mjs";
// src/git.ts
import { promises as fs } from "fs";
import git from "isomorphic-git";
var commitChangesFromRepo = async ({
base,
repoDirectory = process.cwd(),
log,
...otherArgs
}) => {
const ref = base?.commit ?? "HEAD";
const gitLog = await git.log({
fs,
dir: repoDirectory,
ref,
depth: 1
});
const oid = gitLog[0]?.oid;
if (!oid) {
throw new Error(`Could not determine oid for ${ref}`);
}
const trees = [git.TREE({ ref: oid }), git.WORKDIR()];
const additions = [];
const deletions = [];
const fileChanges = {
additions,
deletions
};
await git.walk({
fs,
dir: repoDirectory,
trees,
map: async (filepath, [commit, workdir]) => {
const prevOid = await commit?.oid();
const currentOid = await workdir?.oid();
if (prevOid === currentOid && !commit === !workdir) {
return null;
}
if (await git.isIgnored({
fs,
dir: repoDirectory,
filepath
})) {
return null;
}
if (await commit?.type() === "tree" || await workdir?.type() === "tree") {
return true;
}
if (!workdir) {
deletions.push(filepath);
return null;
} else {
const arr = await workdir.content();
if (!arr) {
throw new Error(`Could not determine content of file ${filepath}`);
}
additions.push({
path: filepath,
contents: Buffer.from(arr)
});
}
return true;
}
});
return commitFilesFromBuffers({
...otherArgs,
fileChanges,
log,
base: {
commit: oid
}
});
};
export {
commitChangesFromRepo
};
type Maybe<T> = T | null;
type InputMaybe<T> = Maybe<T>;
type Exact<T extends {
[key: string]: unknown;
}> = {
[K in keyof T]: T[K];
};
/** All built-in and custom scalars, mapped to their actual values */
type Scalars = {
ID: {
input: string;
output: string;
};
String: {
input: string;
output: string;
};
Boolean: {
input: boolean;
output: boolean;
};
Int: {
input: number;
output: number;
};
Float: {
input: number;
output: number;
};
Base64String: {
input: any;
output: any;
};
BigInt: {
input: any;
output: any;
};
Date: {
input: any;
output: any;
};
DateTime: {
input: any;
output: any;
};
GitObjectID: {
input: any;
output: any;
};
GitSSHRemote: {
input: any;
output: any;
};
GitTimestamp: {
input: any;
output: any;
};
HTML: {
input: any;
output: any;
};
PreciseDateTime: {
input: any;
output: any;
};
URI: {
input: any;
output: any;
};
X509Certificate: {
input: any;
output: any;
};
};
/** A message to include with a new commit */
type CommitMessage = {
/** The body of the message. */
body?: InputMaybe<Scalars['String']['input']>;
/** The headline of the message. */
headline: Scalars['String']['input'];
};
/**
* A git ref for a commit to be appended to.
*
* The ref must be a branch, i.e. its fully qualified name must start
* with `refs/heads/` (although the input is not required to be fully
* qualified).
*
* The Ref may be specified by its global node ID or by the
* `repositoryNameWithOwner` and `branchName`.
*
* ### Examples
*
* Specify a branch using a global node ID:
*
* { "id": "MDM6UmVmMTpyZWZzL2hlYWRzL21haW4=" }
*
* Specify a branch using `repositoryNameWithOwner` and `branchName`:
*
* {
* "repositoryNameWithOwner": "github/graphql-client",
* "branchName": "main"
* }
*
*
*/
type CommittableBranch = {
/** The unqualified name of the branch to append the commit to. */
branchName?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be updated. */
id?: InputMaybe<Scalars['ID']['input']>;
/** The nameWithOwner of the repository to commit to. */
repositoryNameWithOwner?: InputMaybe<Scalars['String']['input']>;
};
/** Autogenerated input type of CreateCommitOnBranch */
type CreateCommitOnBranchInput = {
/** The Ref to be updated. Must be a branch. */
branch: CommittableBranch;
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The git commit oid expected at the head of the branch prior to the commit */
expectedHeadOid: Scalars['GitObjectID']['input'];
/** A description of changes to files in this commit. */
fileChanges?: InputMaybe<FileChanges>;
/** The commit message the be included with the commit. */
message: CommitMessage;
};
/** Autogenerated input type of CreateRef */
type CreateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The fully qualified name of the new Ref (ie: `refs/heads/my_new_branch`). */
name: Scalars['String']['input'];
/** The GitObjectID that the new Ref shall target. Must point to a commit. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Repository to create the Ref in. */
repositoryId: Scalars['ID']['input'];
};
/** Autogenerated input type of DeleteRef */
type DeleteRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be deleted. */
refId: Scalars['ID']['input'];
};
/** A command to add a file at the given path with the given contents as part of a commit. Any existing file at that that path will be replaced. */
type FileAddition = {
/** The base64 encoded contents of the file */
contents: Scalars['Base64String']['input'];
/** The path in the repository where the file will be located */
path: Scalars['String']['input'];
};
/**
* A description of a set of changes to a file tree to be made as part of
* a git commit, modeled as zero or more file `additions` and zero or more
* file `deletions`.
*
* Both fields are optional; omitting both will produce a commit with no
* file changes.
*
* `deletions` and `additions` describe changes to files identified
* by their path in the git tree using unix-style path separators, i.e.
* `/`. The root of a git tree is an empty string, so paths are not
* slash-prefixed.
*
* `path` values must be unique across all `additions` and `deletions`
* provided. Any duplication will result in a validation error.
*
* ### Encoding
*
* File contents must be provided in full for each `FileAddition`.
*
* The `contents` of a `FileAddition` must be encoded using RFC 4648
* compliant base64, i.e. correct padding is required and no characters
* outside the standard alphabet may be used. Invalid base64
* encoding will be rejected with a validation error.
*
* The encoded contents may be binary.
*
* For text files, no assumptions are made about the character encoding of
* the file contents (after base64 decoding). No charset transcoding or
* line-ending normalization will be performed; it is the client's
* responsibility to manage the character encoding of files they provide.
* However, for maximum compatibility we recommend using UTF-8 encoding
* and ensuring that all files in a repository use a consistent
* line-ending convention (`\n` or `\r\n`), and that all files end
* with a newline.
*
* ### Modeling file changes
*
* Each of the the five types of conceptual changes that can be made in a
* git commit can be described using the `FileChanges` type as follows:
*
* 1. New file addition: create file `hello world\n` at path `docs/README.txt`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
* 2. Existing file modification: change existing `docs/README.txt` to have new
* content `new content here\n`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("new content here\n")
* }
* ]
* }
*
* 3. Existing file deletion: remove existing file `docs/README.txt`.
* Note that the path is required to exist -- specifying a
* path that does not exist on the given branch will abort the
* commit and return an error.
*
* {
* "deletions" [
* {
* "path": "docs/README.txt"
* }
* ]
* }
*
*
* 4. File rename with no changes: rename `docs/README.txt` with
* previous content `hello world\n` to the same content at
* `newdocs/README.txt`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
*
* 5. File rename with changes: rename `docs/README.txt` with
* previous content `hello world\n` to a file at path
* `newdocs/README.txt` with content `new contents\n`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("new contents\n")
* }
* ]
* }
*
*/
type FileChanges = {
/** File to add or change. */
additions?: InputMaybe<Array<FileAddition>>;
/** Files to delete. */
deletions?: InputMaybe<Array<FileDeletion>>;
};
/** A command to delete the file at the given path as part of a commit. */
type FileDeletion = {
/** The path to delete */
path: Scalars['String']['input'];
};
/** Autogenerated input type of UpdateRef */
type UpdateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** Permit updates of branch Refs that are not fast-forwards? */
force?: InputMaybe<Scalars['Boolean']['input']>;
/** The GitObjectID that the Ref shall be updated to target. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Ref to be updated. */
refId: Scalars['ID']['input'];
};
type GetRepositoryMetadataQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
baseRef: Scalars['String']['input'];
targetRef: Scalars['String']['input'];
}>;
type GetRepositoryMetadataQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
id: string;
baseRef?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
target: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
};
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
targetBranch?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
} | null;
};
type CreateRefMutationVariables = Exact<{
input: CreateRefInput;
}>;
type CreateRefMutation = {
__typename?: 'Mutation';
createRef?: {
__typename?: 'CreateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type UpdateRefMutationVariables = Exact<{
input: UpdateRefInput;
}>;
type UpdateRefMutation = {
__typename?: 'Mutation';
updateRef?: {
__typename?: 'UpdateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type DeleteRefMutationVariables = Exact<{
input: DeleteRefInput;
}>;
type DeleteRefMutation = {
__typename?: 'Mutation';
deleteRef?: {
__typename?: 'DeleteRefPayload';
clientMutationId?: string | null;
} | null;
};
type CreateCommitOnBranchMutationVariables = Exact<{
input: CreateCommitOnBranchInput;
}>;
type CreateCommitOnBranchMutation = {
__typename?: 'Mutation';
createCommitOnBranch?: {
__typename?: 'CreateCommitOnBranchPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type GetRefTreeQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
ref: Scalars['String']['input'];
path: Scalars['String']['input'];
}>;
type GetRefTreeQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
ref?: {
__typename?: 'Ref';
target?: {
__typename?: 'Blob';
} | {
__typename?: 'Commit';
message: string;
tree: {
__typename?: 'Tree';
oid: any;
};
parents: {
__typename?: 'CommitConnection';
nodes?: Array<{
__typename?: 'Commit';
oid: any;
} | null> | null;
};
file?: {
__typename?: 'TreeEntry';
oid: any;
} | null;
} | {
__typename?: 'Tag';
} | {
__typename?: 'Tree';
} | null;
} | null;
} | null;
};
type GitHubClient = {
graphql: <T>(query: string, variables: any) => Promise<T>;
};
declare const getRepositoryMetadata: (o: GitHubClient, v: GetRepositoryMetadataQueryVariables) => Promise<GetRepositoryMetadataQuery["repository"]>;
declare const createRefMutation: (o: GitHubClient, v: CreateRefMutationVariables) => Promise<CreateRefMutation>;
declare const updateRefMutation: (o: GitHubClient, v: UpdateRefMutationVariables) => Promise<UpdateRefMutation>;
declare const deleteRefMutation: (o: GitHubClient, v: DeleteRefMutationVariables) => Promise<DeleteRefMutation>;
declare const createCommitOnBranchQuery: (o: GitHubClient, v: CreateCommitOnBranchMutationVariables) => Promise<CreateCommitOnBranchMutation>;
declare const getRefTreeQuery: (o: GitHubClient, v: GetRefTreeQueryVariables) => Promise<GetRefTreeQuery>;
type queries_GitHubClient = GitHubClient;
declare const queries_createCommitOnBranchQuery: typeof createCommitOnBranchQuery;
declare const queries_createRefMutation: typeof createRefMutation;
declare const queries_deleteRefMutation: typeof deleteRefMutation;
declare const queries_getRefTreeQuery: typeof getRefTreeQuery;
declare const queries_getRepositoryMetadata: typeof getRepositoryMetadata;
declare const queries_updateRefMutation: typeof updateRefMutation;
declare namespace queries {
export { type queries_GitHubClient as GitHubClient, queries_createCommitOnBranchQuery as createCommitOnBranchQuery, queries_createRefMutation as createRefMutation, queries_deleteRefMutation as deleteRefMutation, queries_getRefTreeQuery as getRefTreeQuery, queries_getRepositoryMetadata as getRepositoryMetadata, queries_updateRefMutation as updateRefMutation };
}
interface Logger {
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
debug(msg: string): void;
}
type CommitFilesResult = {
refId: string | null;
};
type GitBase = {
branch: string;
} | {
tag: string;
} | {
commit: string;
};
interface CommitFilesBasedArgs {
octokit: GitHubClient;
owner: string;
repo?: string;
/** @deprecated use {@link repo} instead */
repository?: string;
branch: string;
/**
* Push the commit even if the branch exists and does not match what was
* specified as the base.
*/
force?: boolean;
/**
* The commit message
*/
message: string | CommitMessage;
log?: Logger;
}
interface CommitFilesSharedArgsWithBase extends CommitFilesBasedArgs {
/**
* The current branch, tag or commit that the new branch should be based on.
*/
base: GitBase;
}
interface CommitFilesFromBase64Args extends CommitFilesSharedArgsWithBase {
fileChanges: FileChanges;
}
interface CommitFilesFromBuffersArgs extends CommitFilesSharedArgsWithBase {
/**
* The file changes, relative to the repository root, to make to the specified branch.
*/
fileChanges: {
additions?: Array<{
path: string;
contents: Buffer;
}>;
deletions?: string[];
};
}
interface CommitFilesFromDirectoryArgs extends CommitFilesSharedArgsWithBase {
/**
* The directory to consider the root of the repository when calculating
* file paths
*/
workingDirectory?: string;
/**
* The file paths, relative to {@link workingDirectory},
* to add or delete from the branch on GitHub.
*/
fileChanges: {
/** File paths, relative to {@link workingDirectory}, to remove from the repo. */
additions?: string[];
/** File paths, relative to the repository root, to remove from the repo. */
deletions?: string[];
};
}
interface CommitChangesFromRepoArgs extends CommitFilesBasedArgs {
/**
* The base commit to build your changes on-top of.
*
* By default, this commit will be the HEAD of the local repository,
* meaning that if any commits have been made locally and not pushed,
* this command will fail.
*
* To include all changes, this should be set to a commit that is known
* to be in the remote repository (such as the default branch).
*
* If you want to base the changes on a different commit to one checked out,
* make sure that you also pull this commit from the remote.
*
* @default HEAD
*/
base?: {
commit: string;
};
/**
* The root of the repository.
*
* @default process.cwd()
*/
repoDirectory?: string;
}
export { type CommitFilesFromBase64Args as C, type CommitFilesResult as a, type CommitFilesFromDirectoryArgs as b, type CommitChangesFromRepoArgs as c, type CommitFilesFromBuffersArgs as d, queries as q };
type Maybe<T> = T | null;
type InputMaybe<T> = Maybe<T>;
type Exact<T extends {
[key: string]: unknown;
}> = {
[K in keyof T]: T[K];
};
/** All built-in and custom scalars, mapped to their actual values */
type Scalars = {
ID: {
input: string;
output: string;
};
String: {
input: string;
output: string;
};
Boolean: {
input: boolean;
output: boolean;
};
Int: {
input: number;
output: number;
};
Float: {
input: number;
output: number;
};
Base64String: {
input: any;
output: any;
};
BigInt: {
input: any;
output: any;
};
Date: {
input: any;
output: any;
};
DateTime: {
input: any;
output: any;
};
GitObjectID: {
input: any;
output: any;
};
GitSSHRemote: {
input: any;
output: any;
};
GitTimestamp: {
input: any;
output: any;
};
HTML: {
input: any;
output: any;
};
PreciseDateTime: {
input: any;
output: any;
};
URI: {
input: any;
output: any;
};
X509Certificate: {
input: any;
output: any;
};
};
/** A message to include with a new commit */
type CommitMessage = {
/** The body of the message. */
body?: InputMaybe<Scalars['String']['input']>;
/** The headline of the message. */
headline: Scalars['String']['input'];
};
/**
* A git ref for a commit to be appended to.
*
* The ref must be a branch, i.e. its fully qualified name must start
* with `refs/heads/` (although the input is not required to be fully
* qualified).
*
* The Ref may be specified by its global node ID or by the
* `repositoryNameWithOwner` and `branchName`.
*
* ### Examples
*
* Specify a branch using a global node ID:
*
* { "id": "MDM6UmVmMTpyZWZzL2hlYWRzL21haW4=" }
*
* Specify a branch using `repositoryNameWithOwner` and `branchName`:
*
* {
* "repositoryNameWithOwner": "github/graphql-client",
* "branchName": "main"
* }
*
*
*/
type CommittableBranch = {
/** The unqualified name of the branch to append the commit to. */
branchName?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be updated. */
id?: InputMaybe<Scalars['ID']['input']>;
/** The nameWithOwner of the repository to commit to. */
repositoryNameWithOwner?: InputMaybe<Scalars['String']['input']>;
};
/** Autogenerated input type of CreateCommitOnBranch */
type CreateCommitOnBranchInput = {
/** The Ref to be updated. Must be a branch. */
branch: CommittableBranch;
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The git commit oid expected at the head of the branch prior to the commit */
expectedHeadOid: Scalars['GitObjectID']['input'];
/** A description of changes to files in this commit. */
fileChanges?: InputMaybe<FileChanges>;
/** The commit message the be included with the commit. */
message: CommitMessage;
};
/** Autogenerated input type of CreateRef */
type CreateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The fully qualified name of the new Ref (ie: `refs/heads/my_new_branch`). */
name: Scalars['String']['input'];
/** The GitObjectID that the new Ref shall target. Must point to a commit. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Repository to create the Ref in. */
repositoryId: Scalars['ID']['input'];
};
/** Autogenerated input type of DeleteRef */
type DeleteRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** The Node ID of the Ref to be deleted. */
refId: Scalars['ID']['input'];
};
/** A command to add a file at the given path with the given contents as part of a commit. Any existing file at that that path will be replaced. */
type FileAddition = {
/** The base64 encoded contents of the file */
contents: Scalars['Base64String']['input'];
/** The path in the repository where the file will be located */
path: Scalars['String']['input'];
};
/**
* A description of a set of changes to a file tree to be made as part of
* a git commit, modeled as zero or more file `additions` and zero or more
* file `deletions`.
*
* Both fields are optional; omitting both will produce a commit with no
* file changes.
*
* `deletions` and `additions` describe changes to files identified
* by their path in the git tree using unix-style path separators, i.e.
* `/`. The root of a git tree is an empty string, so paths are not
* slash-prefixed.
*
* `path` values must be unique across all `additions` and `deletions`
* provided. Any duplication will result in a validation error.
*
* ### Encoding
*
* File contents must be provided in full for each `FileAddition`.
*
* The `contents` of a `FileAddition` must be encoded using RFC 4648
* compliant base64, i.e. correct padding is required and no characters
* outside the standard alphabet may be used. Invalid base64
* encoding will be rejected with a validation error.
*
* The encoded contents may be binary.
*
* For text files, no assumptions are made about the character encoding of
* the file contents (after base64 decoding). No charset transcoding or
* line-ending normalization will be performed; it is the client's
* responsibility to manage the character encoding of files they provide.
* However, for maximum compatibility we recommend using UTF-8 encoding
* and ensuring that all files in a repository use a consistent
* line-ending convention (`\n` or `\r\n`), and that all files end
* with a newline.
*
* ### Modeling file changes
*
* Each of the the five types of conceptual changes that can be made in a
* git commit can be described using the `FileChanges` type as follows:
*
* 1. New file addition: create file `hello world\n` at path `docs/README.txt`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
* 2. Existing file modification: change existing `docs/README.txt` to have new
* content `new content here\n`:
*
* {
* "additions" [
* {
* "path": "docs/README.txt",
* "contents": base64encode("new content here\n")
* }
* ]
* }
*
* 3. Existing file deletion: remove existing file `docs/README.txt`.
* Note that the path is required to exist -- specifying a
* path that does not exist on the given branch will abort the
* commit and return an error.
*
* {
* "deletions" [
* {
* "path": "docs/README.txt"
* }
* ]
* }
*
*
* 4. File rename with no changes: rename `docs/README.txt` with
* previous content `hello world\n` to the same content at
* `newdocs/README.txt`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("hello world\n")
* }
* ]
* }
*
*
* 5. File rename with changes: rename `docs/README.txt` with
* previous content `hello world\n` to a file at path
* `newdocs/README.txt` with content `new contents\n`:
*
* {
* "deletions" [
* {
* "path": "docs/README.txt",
* }
* ],
* "additions" [
* {
* "path": "newdocs/README.txt",
* "contents": base64encode("new contents\n")
* }
* ]
* }
*
*/
type FileChanges = {
/** File to add or change. */
additions?: InputMaybe<Array<FileAddition>>;
/** Files to delete. */
deletions?: InputMaybe<Array<FileDeletion>>;
};
/** A command to delete the file at the given path as part of a commit. */
type FileDeletion = {
/** The path to delete */
path: Scalars['String']['input'];
};
/** Autogenerated input type of UpdateRef */
type UpdateRefInput = {
/** A unique identifier for the client performing the mutation. */
clientMutationId?: InputMaybe<Scalars['String']['input']>;
/** Permit updates of branch Refs that are not fast-forwards? */
force?: InputMaybe<Scalars['Boolean']['input']>;
/** The GitObjectID that the Ref shall be updated to target. */
oid: Scalars['GitObjectID']['input'];
/** The Node ID of the Ref to be updated. */
refId: Scalars['ID']['input'];
};
type GetRepositoryMetadataQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
baseRef: Scalars['String']['input'];
targetRef: Scalars['String']['input'];
}>;
type GetRepositoryMetadataQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
id: string;
baseRef?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
target: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
};
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
targetBranch?: {
__typename?: 'Ref';
id: string;
target?: {
__typename?: 'Blob';
oid: any;
} | {
__typename?: 'Commit';
oid: any;
} | {
__typename?: 'Tag';
oid: any;
} | {
__typename?: 'Tree';
oid: any;
} | null;
} | null;
} | null;
};
type CreateRefMutationVariables = Exact<{
input: CreateRefInput;
}>;
type CreateRefMutation = {
__typename?: 'Mutation';
createRef?: {
__typename?: 'CreateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type UpdateRefMutationVariables = Exact<{
input: UpdateRefInput;
}>;
type UpdateRefMutation = {
__typename?: 'Mutation';
updateRef?: {
__typename?: 'UpdateRefPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type DeleteRefMutationVariables = Exact<{
input: DeleteRefInput;
}>;
type DeleteRefMutation = {
__typename?: 'Mutation';
deleteRef?: {
__typename?: 'DeleteRefPayload';
clientMutationId?: string | null;
} | null;
};
type CreateCommitOnBranchMutationVariables = Exact<{
input: CreateCommitOnBranchInput;
}>;
type CreateCommitOnBranchMutation = {
__typename?: 'Mutation';
createCommitOnBranch?: {
__typename?: 'CreateCommitOnBranchPayload';
ref?: {
__typename?: 'Ref';
id: string;
} | null;
} | null;
};
type GetRefTreeQueryVariables = Exact<{
owner: Scalars['String']['input'];
repo: Scalars['String']['input'];
ref: Scalars['String']['input'];
path: Scalars['String']['input'];
}>;
type GetRefTreeQuery = {
__typename?: 'Query';
repository?: {
__typename?: 'Repository';
ref?: {
__typename?: 'Ref';
target?: {
__typename?: 'Blob';
} | {
__typename?: 'Commit';
message: string;
tree: {
__typename?: 'Tree';
oid: any;
};
parents: {
__typename?: 'CommitConnection';
nodes?: Array<{
__typename?: 'Commit';
oid: any;
} | null> | null;
};
file?: {
__typename?: 'TreeEntry';
oid: any;
} | null;
} | {
__typename?: 'Tag';
} | {
__typename?: 'Tree';
} | null;
} | null;
} | null;
};
type GitHubClient = {
graphql: <T>(query: string, variables: any) => Promise<T>;
};
declare const getRepositoryMetadata: (o: GitHubClient, v: GetRepositoryMetadataQueryVariables) => Promise<GetRepositoryMetadataQuery["repository"]>;
declare const createRefMutation: (o: GitHubClient, v: CreateRefMutationVariables) => Promise<CreateRefMutation>;
declare const updateRefMutation: (o: GitHubClient, v: UpdateRefMutationVariables) => Promise<UpdateRefMutation>;
declare const deleteRefMutation: (o: GitHubClient, v: DeleteRefMutationVariables) => Promise<DeleteRefMutation>;
declare const createCommitOnBranchQuery: (o: GitHubClient, v: CreateCommitOnBranchMutationVariables) => Promise<CreateCommitOnBranchMutation>;
declare const getRefTreeQuery: (o: GitHubClient, v: GetRefTreeQueryVariables) => Promise<GetRefTreeQuery>;
type queries_GitHubClient = GitHubClient;
declare const queries_createCommitOnBranchQuery: typeof createCommitOnBranchQuery;
declare const queries_createRefMutation: typeof createRefMutation;
declare const queries_deleteRefMutation: typeof deleteRefMutation;
declare const queries_getRefTreeQuery: typeof getRefTreeQuery;
declare const queries_getRepositoryMetadata: typeof getRepositoryMetadata;
declare const queries_updateRefMutation: typeof updateRefMutation;
declare namespace queries {
export { type queries_GitHubClient as GitHubClient, queries_createCommitOnBranchQuery as createCommitOnBranchQuery, queries_createRefMutation as createRefMutation, queries_deleteRefMutation as deleteRefMutation, queries_getRefTreeQuery as getRefTreeQuery, queries_getRepositoryMetadata as getRepositoryMetadata, queries_updateRefMutation as updateRefMutation };
}
interface Logger {
info(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
debug(msg: string): void;
}
type CommitFilesResult = {
refId: string | null;
};
type GitBase = {
branch: string;
} | {
tag: string;
} | {
commit: string;
};
interface CommitFilesBasedArgs {
octokit: GitHubClient;
owner: string;
repo?: string;
/** @deprecated use {@link repo} instead */
repository?: string;
branch: string;
/**
* Push the commit even if the branch exists and does not match what was
* specified as the base.
*/
force?: boolean;
/**
* The commit message
*/
message: string | CommitMessage;
log?: Logger;
}
interface CommitFilesSharedArgsWithBase extends CommitFilesBasedArgs {
/**
* The current branch, tag or commit that the new branch should be based on.
*/
base: GitBase;
}
interface CommitFilesFromBase64Args extends CommitFilesSharedArgsWithBase {
fileChanges: FileChanges;
}
interface CommitFilesFromBuffersArgs extends CommitFilesSharedArgsWithBase {
/**
* The file changes, relative to the repository root, to make to the specified branch.
*/
fileChanges: {
additions?: Array<{
path: string;
contents: Buffer;
}>;
deletions?: string[];
};
}
interface CommitFilesFromDirectoryArgs extends CommitFilesSharedArgsWithBase {
/**
* The directory to consider the root of the repository when calculating
* file paths
*/
workingDirectory?: string;
/**
* The file paths, relative to {@link workingDirectory},
* to add or delete from the branch on GitHub.
*/
fileChanges: {
/** File paths, relative to {@link workingDirectory}, to remove from the repo. */
additions?: string[];
/** File paths, relative to the repository root, to remove from the repo. */
deletions?: string[];
};
}
interface CommitChangesFromRepoArgs extends CommitFilesBasedArgs {
/**
* The base commit to build your changes on-top of.
*
* By default, this commit will be the HEAD of the local repository,
* meaning that if any commits have been made locally and not pushed,
* this command will fail.
*
* To include all changes, this should be set to a commit that is known
* to be in the remote repository (such as the default branch).
*
* If you want to base the changes on a different commit to one checked out,
* make sure that you also pull this commit from the remote.
*
* @default HEAD
*/
base?: {
commit: string;
};
/**
* The root of the repository.
*
* @default process.cwd()
*/
repoDirectory?: string;
}
export { type CommitFilesFromBase64Args as C, type CommitFilesResult as a, type CommitFilesFromDirectoryArgs as b, type CommitChangesFromRepoArgs as c, type CommitFilesFromBuffersArgs as d, queries as q };