octokit-plugin-create-pull-request
Version:
Octokit plugin to create a pull request with multiple file changes
36 lines (35 loc) • 632 B
JavaScript
async function valueToTreeObject(octokit, owner, repo, path, value) {
const defaultMode = "100644";
if (typeof value === "string") {
return {
path,
mode: defaultMode,
content: value
};
}
const mode = value.mode ?? defaultMode;
if (value.encoding === "utf-8") {
return {
path,
mode,
content: value.content
};
}
const { data } = await octokit.request(
"POST /repos/{owner}/{repo}/git/blobs",
{
owner,
repo,
...value
}
);
const blobSha = data.sha;
return {
path,
mode,
sha: blobSha
};
}
export {
valueToTreeObject
};