2021-12-02 18:09:16 +00:00
|
|
|
|
Aspirationally, a set of helpers
|
|
|
|
|
to simplify working with Git LFS through Isomorphic Git.
|
2021-11-25 12:27:33 +00:00
|
|
|
|
|
|
|
|
|
|
2021-12-02 18:07:21 +00:00
|
|
|
|
== Installation
|
|
|
|
|
|
|
|
|
|
Peer dependencies:
|
|
|
|
|
|
|
|
|
|
- Isomorphic Git ^1.7.0
|
|
|
|
|
- @aws-crypto/sha256-universal ^2.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
== Usage
|
|
|
|
|
|
|
|
|
|
As of 0.1.6, API offers the following functions:
|
2021-11-25 12:27:33 +00:00
|
|
|
|
|
|
|
|
|
|
2021-12-02 18:07:21 +00:00
|
|
|
|
- `downloadBlobFromPointer({ http, headers, url, auth }, lfsPointer) => Buffer`
|
2021-11-25 12:27:33 +00:00
|
|
|
|
+
|
|
|
|
|
where `http` is an `HttpClient` as supported by Isomorphic Git,
|
|
|
|
|
URL is repository URL
|
2021-11-25 12:29:04 +00:00
|
|
|
|
and `lfsPointer` is an object returned by `readPointer()`.
|
2021-12-02 18:07:21 +00:00
|
|
|
|
+
|
|
|
|
|
Uses cache, if the object had been previously retrieved.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- `uploadBlob({ http, headers, url, auth }, buffer) => LFSPointerInfo`
|
|
|
|
|
+
|
|
|
|
|
where first argument is the same as for the download function,
|
|
|
|
|
and returned pointer info can be used to write a pointer file in place
|
|
|
|
|
of actual object in Git repository (pass it through `formatPointerInfo()`).
|
|
|
|
|
|
|
|
|
|
|
2021-12-02 18:11:58 +00:00
|
|
|
|
- `readPointer({ dir, gitdir, content }) => LFSPointer`
|
2021-12-02 18:07:21 +00:00
|
|
|
|
+
|
|
|
|
|
where `dir`, `gitdir` behavior mimics that of Isomorphic Git,
|
|
|
|
|
and `content` is a `Buffer`.
|
|
|
|
|
|
|
|
|
|
|
2021-12-02 18:11:58 +00:00
|
|
|
|
- `readPointerInfo(buffer) => LFSPointerInfo`
|
2021-12-02 18:07:21 +00:00
|
|
|
|
+
|
|
|
|
|
reads a properly formatted LFS pointer within a Git repository.
|
|
|
|
|
|
|
|
|
|
|
2021-12-02 18:11:58 +00:00
|
|
|
|
- `formatPointerInfo(lfsPointerInfo) => Buffer`
|
2021-12-02 18:07:21 +00:00
|
|
|
|
+
|
|
|
|
|
converts pointer info to appropriately formatted blob
|
|
|
|
|
suitable to be stored in Git repository in place of actual object data.
|
|
|
|
|
|
2021-11-25 12:27:33 +00:00
|
|
|
|
|
|
|
|
|
- `populateCache(workDir, ref?)`
|
|
|
|
|
+
|
|
|
|
|
where `workDir` is a path to working directory,
|
|
|
|
|
and `ref` should probably be left at the default `"HEAD"`.
|
2021-12-02 18:11:58 +00:00
|
|
|
|
+
|
|
|
|
|
NOTE: Very tentative API.
|
2021-12-02 18:07:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
== Known shortcomings
|
|
|
|
|
|
|
|
|
|
- Works in Node runtime only
|
|
|
|
|
- @aws-crypto/sha256-universal peer dependency is unnecessary.
|
|
|
|
|
If we’re Node-only we can probably achieve the same using Node’s `crypto` module,
|
|
|
|
|
and if not we should place it in actual `dependencies`.
|
|
|
|
|
|
|
|
|
|
== Considered within scope
|
|
|
|
|
|
|
|
|
|
- Implement batch uploads and downloads (parallelise requests? use native batch API?)
|
|
|
|
|
- Find a way to generalize UA header handling
|
|
|
|
|
- Make it work in browser runtime as well (if feasible?)
|