# memfs-or-file-map-to-github-branch

> Handles making a GitHub branch with the commits from a memfs instance or a file map

Latest version **1.3.0** (published 2025-03-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install memfs-or-file-map-to-github-branch
pnpm add memfs-or-file-map-to-github-branch
yarn add memfs-or-file-map-to-github-branch
bun add memfs-or-file-map-to-github-branch
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2025-03-12 |
| First published | 2018-09-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | orta |
| Maintainers | orta |

## Links

- npm: https://www.npmjs.com/package/memfs-or-file-map-to-github-branch
- Repository: https://github.com/orta/memfs-or-file-map-to-github-branch
- Homepage: https://github.com/orta/memfs-or-file-map-to-github-branch#readme
- Issues: https://github.com/orta/memfs-or-file-map-to-github-branch/issues
- npm.io page: https://npm.io/package/memfs-or-file-map-to-github-branch

## Dependencies (1)

- [@octokit/rest](https://npm.io/package/@octokit/rest.md) *

## Recent versions

- 1.3.0 (latest) — 2025-03-12
- 1.2.1 — 2022-02-01
- 1.2.0 — 2020-02-03
- 1.1.2 — 2018-10-11
- 1.1.1 — 2018-10-11
- 1.1.0 — 2018-09-30
- 1.0.6 — 2018-09-29
- 1.0.5 — 2018-09-29
- 1.0.4 — 2018-09-29
- 1.0.3 — 2018-09-29
- 1.0.2 — 2018-09-29
- 1.0.1 — 2018-09-29
- 1.0.0 — 2018-09-03

## README

## Take a Source Object and Make a Branch via the GitHub API

e.g. this:

```ts
const settings = {
  owner: "danger",
  repo: "danger-js",
  fullBranchReference: "heads/new_readme",
  message: "Adds some new stuff"
}

// This will make a make a new commit on the branch new_readme, changing README.md
await filepathContentsMapToUpdateGitHubBranch(api, { "README.md": "### My README" }, settings)
```

and it will make a branch on that repo with those new file contents.

---

## Full API Reference

```ts
/**
 * The config for creating a branch. Noting the repo,
 * base branch (what should it work from), the new branch
 * and the message for the generated commit. The commit's
 * author will be whomever the API is authenticated with.
 */
export interface BranchCreationConfig {
  /** The danger in danger/danger-js */
  owner: string
  /** The danger-js in danger/danger-js */
  repo: string
  /** Base branch to start working from, null is implied to be `heads/master` */
  fullBaseBranch?: string
  /** The ref in the URL must `heads/branch`, not just `branch`. */
  fullBranchReference: string
  /** Message for the commit */
  message: string
}
/** Basically a filename to file contents map */
interface FileMap {
  [filename: string]: string
}
/**
 * Creates a bunch of blobs, wraps them in a tree, updates a reference from a memfs volume
 */
export declare const memFSToGitHubCommits: (
  api: GitHub,
  volume: MemFSVolume,
  settings: BranchCreationConfig
) => Promise<void>
/**
 * Creates a bunch of blobs, wraps them in a tree, updates a reference from a map of files to contents
 */
export declare const filepathContentsMapToUpdateGitHubBranch: (
  api: GitHub,
  fileMap: FileMap,
  settings: BranchCreationConfig
) => Promise<void>
/**
 * A Git tree object creates the hierarchy between files in a Git repository. To create a tree
 * we need to make a list of blobs (which represent changes to the FS)
 *
 * We want to build on top of the tree that already exists at the last sha
 *
 * https://developer.github.com/v3/git/trees/
 */
export declare const createTree: (
  api: GitHub,
  settings: BranchCreationConfig
) => (fileMap: FileMap, baseSha: string) => Promise<GitHub.GitdataCreateTreeResponse>
/**
 * A Git commit is a snapshot of the hierarchy (Git tree) and the contents of the files (Git blob) in a Git repository
 *
 * https://developer.github.com/v3/git/commits/
 */
export declare const createACommit: (
  api: GitHub,
  settings: BranchCreationConfig
) => (treeSha: string, parentSha: string) => Promise<GitHub.Response<GitHub.GitdataCreateCommitResponse>>
/**
 * A Git reference (git ref) is just a file that contains a Git commit SHA-1 hash. When referring
 * to a Git commit, you can use the Git reference, which is an easy-to-remember name, rather than
 * the hash. The Git reference can be rewritten to point to a new commit.
 *
 * https://developer.github.com/v3/git/refs/#git-references
 */
export declare const updateReference: (
  api: GitHub,
  settings: BranchCreationConfig
) => (newSha: string) => Promise<GitHub.Response<GitHub.GitdataCreateReferenceResponse>>
export {}
```

---
_Source: https://npm.io/package/memfs-or-file-map-to-github-branch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
