feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
46
api.hyungi.net/node_modules/js-git/doc/lib/config-codec.md
generated
vendored
Normal file
46
api.hyungi.net/node_modules/js-git/doc/lib/config-codec.md
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Config Codec
|
||||
|
||||
This module implements a codec for reading and writing git config files (this
|
||||
includes the .gitmodules file). As far as I can tell, this is a variant of
|
||||
the INI format.
|
||||
|
||||
## codec.decode(ini) -> config
|
||||
|
||||
Given the text of the config file, return the data as an object.
|
||||
|
||||
The following config:
|
||||
|
||||
```ini
|
||||
[user]
|
||||
name = Tim Caswell
|
||||
email = tim@creationix.com
|
||||
[color]
|
||||
ui = true
|
||||
[color "branch"]
|
||||
current = yellow bold
|
||||
local = green bold
|
||||
remote = cyan bold
|
||||
```
|
||||
|
||||
Will parse to this js object
|
||||
|
||||
```js
|
||||
{
|
||||
user: {
|
||||
name: "Tim Caswell",
|
||||
email: "tim@creationix.com"
|
||||
},
|
||||
color: {
|
||||
ui: "true",
|
||||
branch: {
|
||||
current: "yellow bold",
|
||||
local: "green bold",
|
||||
remote: "cyan bold"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## codec.encode(config) -> ini
|
||||
|
||||
This reverses the conversion and writes a string from a config object.
|
||||
11
api.hyungi.net/node_modules/js-git/doc/lib/deflate.md
generated
vendored
Normal file
11
api.hyungi.net/node_modules/js-git/doc/lib/deflate.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Deflate
|
||||
|
||||
This module implements a simple interface that when normal given data, returns the deflated version in a callback. This wraps the pako dependency.
|
||||
|
||||
## deflate(inflated) => deflated
|
||||
|
||||
```js
|
||||
var deflate = require('js-git/lib/deflate');
|
||||
|
||||
var deflated = deflate(original);
|
||||
```
|
||||
23
api.hyungi.net/node_modules/js-git/doc/lib/inflate-stream.md
generated
vendored
Normal file
23
api.hyungi.net/node_modules/js-git/doc/lib/inflate-stream.md
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# Inflate Stream
|
||||
|
||||
This module implements zlib inflate by hand with a special streaming interface.
|
||||
This is used in js-git to inflate git object fragments in a pack-stream.
|
||||
|
||||
## inflateStream(onEmit, onUnused) -> onInput
|
||||
|
||||
```js
|
||||
var onInput = inflateStream(onEmit, onUnused);
|
||||
|
||||
someStream.on("data", function (chunk) {
|
||||
onInput(null, chunk);
|
||||
});
|
||||
|
||||
function onEmit(err, out) {
|
||||
if (err) throw err;
|
||||
// out is a chunk of inflated data
|
||||
}
|
||||
|
||||
function onUnused(chunks) {
|
||||
// chunks is an array of extra buffers or buffer slices.
|
||||
}
|
||||
```
|
||||
11
api.hyungi.net/node_modules/js-git/doc/lib/inflate.md
generated
vendored
Normal file
11
api.hyungi.net/node_modules/js-git/doc/lib/inflate.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Inflate
|
||||
|
||||
This module implements a simple interface that when given deflated data returns the inflated version.
|
||||
|
||||
## inflate(deflated) -> inflated
|
||||
|
||||
```js
|
||||
var inflate = require('js-git/lib/inflate');
|
||||
|
||||
var inflated = inflate(deflated);
|
||||
```
|
||||
127
api.hyungi.net/node_modules/js-git/doc/lib/object-codec.md
generated
vendored
Normal file
127
api.hyungi.net/node_modules/js-git/doc/lib/object-codec.md
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# Object Codec
|
||||
|
||||
This module implements a codec for the binary git object format for blobs, trees, tags, and commits.
|
||||
|
||||
This library is useful for writing new storage backends. Normal users will probably
|
||||
just use one of the existing mixins for object storage.
|
||||
|
||||
## codec.frame({type,body}) -> buffer
|
||||
|
||||
This function accepts an object with `type` and `body` properties. The `type`
|
||||
property must be one of "blob", "tree", "commit" or "tag". The body can be a
|
||||
pre-encoded raw-buffer or a plain javascript value. See encoder docs below for
|
||||
the formats of the different body types.
|
||||
|
||||
The returned binary value is the fully framed git object. The sha1 of this is
|
||||
the git hash of the object.
|
||||
|
||||
```js
|
||||
var codec = require('js-git/lib/object-codec');
|
||||
var sha1 = require('git-sha1');
|
||||
|
||||
var bin = codec.frame({ type: "blob", body: "Hello World\n"});
|
||||
var hash = sha1(bin);
|
||||
```
|
||||
|
||||
## codec.deframe(buffer, decode) -> {type,body}
|
||||
|
||||
This function accepts a binary git buffer and returns the `{type,body}` object.
|
||||
|
||||
If `decode` is true, then the body will also be decoded into a normal javascript
|
||||
value. If `decode` is false or missing, then the raw-buffer will be in body.
|
||||
|
||||
## codec.encoders
|
||||
|
||||
This is an object containing 4 encoder function Each function has the signature:
|
||||
|
||||
encode(body) -> raw-buffer
|
||||
|
||||
Where body is the JS representation of the type and raw-buffer is the git encoded
|
||||
version of that value, but without the type and length framing.
|
||||
|
||||
```js
|
||||
var encoders = require('js-git/lib/object-codec').encoders;
|
||||
var modes = require('js-git/lib/modes');
|
||||
```
|
||||
|
||||
Blobs must be native binary values (Buffer in node, Uint8Array in browser).
|
||||
It's recommended to either use the `bodec` library to create binary values from
|
||||
strings directly or configure your system with the `formats` mixin that allows
|
||||
for unicode strings when working with blobs.
|
||||
|
||||
```js
|
||||
rawBin = encoders.blob(new Uint8Array([1,2,3,4,5,6]));
|
||||
rawBin = encoders.blob(bodec.fromUnicode("Hello World"));
|
||||
```
|
||||
|
||||
Trees are objects with filename as key and object with {mode,hash} as value.
|
||||
The modes are integers. It's best to use the modes module to help.
|
||||
|
||||
```js
|
||||
rawBin = encoders.tree({ "greeting.txt": {
|
||||
mode: modes.file,
|
||||
hash: blobHash
|
||||
}});
|
||||
```
|
||||
|
||||
Commits are objects with required fields {tree,author,message}
|
||||
Also if there is a single parent, you specify it with `parent`.
|
||||
|
||||
Since a commit can have zero or more parent commits, you specify the parent
|
||||
hashes via the `parents` property as an array of hashes.
|
||||
|
||||
The `author` field is required and contains {name,email,date}.
|
||||
|
||||
Commits also require a `committer` field with the same structure as `author`.
|
||||
|
||||
The `date` property of `author` and `committer` is in the format {seconds,offset}
|
||||
Where seconds is a unix timestamp in seconds and offset is the number of minutes
|
||||
offset for the timezone. (Your local offset can be found with `(new Date).getTimezoneOffset()`)
|
||||
|
||||
The `message` field is mandatory and a simple string.
|
||||
|
||||
```js
|
||||
rawBin = encoders.commit({
|
||||
tree: treeHash,
|
||||
author: {
|
||||
name: "Tim Caswell",
|
||||
email: "tim@creationix.com",
|
||||
date: {
|
||||
seconds: 1391790910,
|
||||
offset: 7 * 60
|
||||
}
|
||||
},
|
||||
parents: [ parentCommitHash ],
|
||||
message: "This is a test commit\n"
|
||||
});
|
||||
```
|
||||
|
||||
Annotated tags are like commits, except they have different fields.
|
||||
|
||||
```js
|
||||
rawBin = encoders.tag({
|
||||
object: commitHash,
|
||||
type: "commit",
|
||||
tag: "mytag",
|
||||
tagger: {
|
||||
name: "Tim Caswell",
|
||||
email: "tim@creationix.com",
|
||||
date: {
|
||||
seconds: 1391790910,
|
||||
offset: 7 * 60
|
||||
}
|
||||
},
|
||||
message: "Tag it!\n"
|
||||
});
|
||||
```
|
||||
|
||||
## codec.decoders
|
||||
|
||||
This is just like `codec.encoders` except these functions do the opposite.
|
||||
They have the format:
|
||||
|
||||
decode(raw-buffer) -> body
|
||||
|
||||
```js
|
||||
var commit = decoders.commit(rawCommitBin);
|
||||
```
|
||||
98
api.hyungi.net/node_modules/js-git/doc/lib/pack-codec.md
generated
vendored
Normal file
98
api.hyungi.net/node_modules/js-git/doc/lib/pack-codec.md
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
# Pack Codec
|
||||
|
||||
This module implements a codec for packfile streams used in the git network
|
||||
protocols as well as the on-disk packfile format.
|
||||
|
||||
These are a sync stream transforms. It accepts an emit function and returns a
|
||||
write function. Both of these have the same interface. You signal `end` to the
|
||||
input side by writing undefined (or nothing) and when emit gets called with
|
||||
undefined that is `end` on the output.
|
||||
|
||||
Since this is sync, errors are simply thrown. If you want to use this in the
|
||||
context of an async stream with back-pressure, it's up to the consumer to handle
|
||||
exceptions and write to the input at the correct rate. Basically to implement
|
||||
back-pressure, you only need to keep writing values to the input till enough
|
||||
data comes out the output. It's sync so by the time `write()` returns, `emit()`
|
||||
will have been called as many times as it ever will (without more writes).
|
||||
|
||||
Here is an example of using the decodePack in a node push stream that ignores
|
||||
backpressure.
|
||||
|
||||
```js
|
||||
var decodePack = require('js-git/lib/pack-codec').decodePack;
|
||||
|
||||
var write = decodePack(onItem);
|
||||
stream.on("data", write);
|
||||
stream.on("end", write);
|
||||
var meta;
|
||||
function onItem(item) {
|
||||
if (item === undefined) {
|
||||
// END of Stream
|
||||
}
|
||||
else if (meta === undefined) {
|
||||
meta = item;
|
||||
}
|
||||
else {
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The first output is the meta object:
|
||||
|
||||
```js
|
||||
{
|
||||
version: 2
|
||||
num: num-of-objects,
|
||||
}
|
||||
```
|
||||
|
||||
## codec.decodePack(emit) -> write
|
||||
|
||||
Input in this is the raw buffer chunks in the packstream. The chunks can be
|
||||
broken up at any point so this is ideal for streaming from a disk or network.
|
||||
|
||||
|
||||
Version is the git pack protocol version, and num is the number of objects that
|
||||
will be in this stream.
|
||||
|
||||
All output objects after this will be raw git objects.
|
||||
|
||||
```js
|
||||
{
|
||||
type: type,
|
||||
size: buffer-size,
|
||||
body: raw-buffer,
|
||||
offset: offset-in-stream,
|
||||
[ref: number-or-hash]
|
||||
}
|
||||
```
|
||||
|
||||
There are two extra types here that aren't seen elsewhere. They are `ofs-delta`
|
||||
and `ref-delta`. In both cases, these are a diff that applies on top of another
|
||||
object in the stream. The different is `ofs-delta` stores a number in `ref`
|
||||
that is the number of bytes to go back in the stream to find the base object.
|
||||
But `ref-delta` includes the full hash of it's base object.
|
||||
|
||||
|
||||
## codec.encodePack(emit) -> write
|
||||
|
||||
This is the reverse. In fact, if you fed this the output from `decodePack`,
|
||||
it's output should match exactly the original stream.
|
||||
|
||||
The objects don't need as much data as the parser outputs. In specefic, the meta
|
||||
object only need contain:
|
||||
|
||||
```js
|
||||
{ num: num-of-objects }
|
||||
```
|
||||
|
||||
And the items only need contain:
|
||||
|
||||
```js
|
||||
{
|
||||
type: type,
|
||||
body: raw-buffer,
|
||||
[ref: number-or-hash]
|
||||
}
|
||||
```
|
||||
53
api.hyungi.net/node_modules/js-git/doc/mixins/fs-db.md
generated
vendored
Normal file
53
api.hyungi.net/node_modules/js-git/doc/mixins/fs-db.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
# Filesystem Git Database
|
||||
|
||||
JSGit repositories need `loadAs`, `saveAs`, `loadRaw`, `saveRaw`, `readRef`, and
|
||||
`updateRef` methods.
|
||||
Depending on the backing storage, there are various ways to implement these
|
||||
methods.
|
||||
The implementation for in-memory storage is `js-git/mixins/mem-db`, and there
|
||||
are variants for using Github or IndexDB for storage.
|
||||
|
||||
The `js-git/mixins/fs-db` implementation provides these methods as well, but
|
||||
depends on a file system interface providing `readFile`, `readChunk`,
|
||||
`writeFile`, and `readDir`.
|
||||
These file system methods are implemented by the `git-fs-db` and
|
||||
`git-chrome-db` packages.
|
||||
|
||||
For the purpose of this document, `=>` implies that the function does not block
|
||||
and accepts a Node.js-style callback.
|
||||
The arrow points to the type of the result.
|
||||
None of these methods need to return a continuable if the nodeback is missing.
|
||||
|
||||
The type `binary` stands for whatever binary representation is appropriate for
|
||||
the underlying platform.
|
||||
For browsers, binary is a `Uint8Array`.
|
||||
For Node.js, binary is a `Buffer`.
|
||||
|
||||
## readFile(path) => binary | undefined
|
||||
|
||||
Reads the entirety of the file at the given path and produces the binary.
|
||||
If the file does not exist, readFile provides `undefined` instead.
|
||||
|
||||
## readChunk(path, start, end) => binary | undefined
|
||||
|
||||
Reads a byte range of the file at the given path.
|
||||
The byte range is a half open interval, including the byte at the initial index,
|
||||
and excluding the byte at the terminal index, such that the end minus the start
|
||||
is the length of the resulting binary data.
|
||||
The end offset may be negative, in which case it should count back from the end
|
||||
of the size of the file at the path, such that the size plus the negative end is
|
||||
the positive end.
|
||||
If the file does not exist, readChunk provides `undefined` instead.
|
||||
|
||||
## writeFile(path, binary) => undefined
|
||||
|
||||
Writes the given bytes to the file at the given path.
|
||||
The method creates any directories leading up to the path if they do not already
|
||||
exist.
|
||||
|
||||
## readDir(path) => array of names | undefined
|
||||
|
||||
Reads the names of the entries in the directory at the given path.
|
||||
The names are not fully qualified paths, just the name of the entry within the
|
||||
given directory.
|
||||
27
api.hyungi.net/node_modules/js-git/doc/mixins/mem-db.md
generated
vendored
Normal file
27
api.hyungi.net/node_modules/js-git/doc/mixins/mem-db.md
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# mem-db mixin
|
||||
|
||||
This mixin implements object store (normal and raw) and stores the data in memory.
|
||||
|
||||
```js
|
||||
var memDb = require('js-git/mixins/mem-db');
|
||||
var repo = {};
|
||||
memDb(repo);
|
||||
repo.saveAs("blob", "Hello World", function (err, hash) {
|
||||
if (err) throw err;
|
||||
console.log("Blob saved with hash " + hash);
|
||||
});
|
||||
```
|
||||
|
||||
This attaches the following interfaces onto the repo object passed in:
|
||||
|
||||
- `saveAs(type, body) => hash`
|
||||
- `loadAs(type, hash) => body`
|
||||
- `loadRaw(hash) => raw-binary`
|
||||
- `saveRaw(hash, raw-binary) =>`
|
||||
|
||||
All these functions are async and accept either a callback last or return a continuable.
|
||||
|
||||
```js
|
||||
// Example using continuable interface from gen-run generator body.
|
||||
var commit = yield repo.loadAs("commit", commitHash);
|
||||
```
|
||||
37
api.hyungi.net/node_modules/js-git/doc/mixins/pack-ops.md
generated
vendored
Normal file
37
api.hyungi.net/node_modules/js-git/doc/mixins/pack-ops.md
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# pack-ops mixin
|
||||
|
||||
This mixin adds the ability to consume or create packfile streams.
|
||||
|
||||
This depends on the repo already having:
|
||||
|
||||
- `loadRaw(hash) => raw-binary`
|
||||
- `saveRaw(hash, raw-binary) =>`
|
||||
|
||||
And then adds:
|
||||
|
||||
- `unpack(stream, opts) => hashes`
|
||||
- `pack(hashes, opts) => stream`
|
||||
|
||||
The streams are simple-stream format. This means they have a `.read(callback)`
|
||||
method for pulling items out of the stream.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var packOps = require('js-git/mixins/pack-ops');
|
||||
packOps(repo);
|
||||
|
||||
repo.unpack(stream, opts, function (err, hashes) {
|
||||
// hashes is imported objects
|
||||
});
|
||||
|
||||
repo.pack(hashes, opts, function (err, stream) {
|
||||
if (err) throw err;
|
||||
stream.read(onRead);
|
||||
function onRead(err, item) {
|
||||
if (err) throw err;
|
||||
console.log(item);
|
||||
if (item) stream.read(onRead);
|
||||
}
|
||||
});
|
||||
```
|
||||
Reference in New Issue
Block a user