Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## /examples

List of examples of using NodeGit to implement common git core operations.

21 changes: 21 additions & 0 deletions generate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## /generate

The scripts and templates in this dir help generate the source code and tests for NodeGit. The major components of generate are:

1. Input
2. Scripts
3. Templates

### Input

All the **configuration** required for the parser to generate the source code and tests. For more details, check the Input directory.

### Scripts

The scripts that generate the final configuration (*snapshot of the library*) `idefs.json`, `missing-tests.json`. These configurations are then used to generate `src` for the library.

### Templates

All the Combyne templates are placed here. The filters, partials, templates all help NodeGit generate the source code.

> For more information on Combyne: [tbranyen/combyne](https://github.com/tbranyen/combyne)
15 changes: 15 additions & 0 deletions generate/input/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## /generate/input
This folder contains the main config files to generate NodeGit

#### Callbacks
Add all meta data about the callbacks from libgit2 that need to be implemented in NodeGit

#### Descriptor
Customize the generated code using this configuration. Enter the function signature, arguments and their metadata and which functions can be skipped in this file. If you're using a manual template, remove all its references from this file.

#### Libgit2-docs
These are provided by the libgit2 team. Includes all metadata about the api provided by the libgit2 library.

#### Libgit2-supplement
Use this confiuration file to group and override parts of the generated code. NodeGit tries it's best to generate the right classes and structs, if that is not the case, use this config file to group/remove the functions.
> If you're using manual templates, update the `cFile` reference to point to the manual template
35 changes: 35 additions & 0 deletions generate/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Manual templates

Manual templates override generated code from nodegit while generating source code. They really should be avoid untill absolutely necessary.

## Why?

#### 1. Performance
> Everytime the library switches between C land and the javascript thread, there is a penalty in performance. If in practice the usage of a method in libgit2 requires crossing the c/javascript boundary frequently, it might be better option to use manual templates. An example being ```Revwalk::FastWalk```.

#### 2. Saftey
> The generated code sometimes does not handle structures that are interdependent. An example would be ```git_patch``` and ```git_diff```. A ```git_patch```'s memory is owned by ```git_diff```, and that includes all of the children of ```git_patch```, as well. So a ```git_diff_hunk```, ```git_diff_line```, and ```git_patch``` all are owned by a ```git_diff```, and when that ```git_diff``` is deleted, all the memory for any patches, hunks, or lines that are in use as NodeGitWrappers are now corrupted. Further, a ```git_diff``` keeps a file handle open for its entire lifespan, which can lead to NodeGit holding onto file locks in Windows. Due to both of these compounding issues, we wrote manual templates to shift ownership away from a ```git_diff``` to ```git_patch```, ```git_diff_hunk```, and ```git_diff_line``` and also shorten the lifespan of a diff.

#### 3. Odd cases
> If a new pattern exists in libgit that would be difficult to implement using generated code, manual templates can be used for one-off cases. Typically generated code takes care of most patterns seen in libgit, but if function signatures do not follow typical pattern, manual templates could be used. Example: ```git_filter``` and ```git_remote_ls```.

<br />
-----
## Implementing manual templates

#### 1. Write manual .cc and .h files to *generate/templates/manual/*
*.cc files -> /generate/templates/manual/src/
*.h files -> /generate/templates/manual/include/

#### 2. Remove all references from /generate configuration files

#### 3. Add references to binding.gyp template
location: /generate/templates/templates/binding.gyp

#### 4. Add headers to nodegit.cc template
location: /generate/templates/templates/nodegit.cc

#### 5. Add new wrapper to nodegit.js template
use rawApi.ManualWrapper reference to add _ManualWrapper
add any js wrapper (if any) via importExtension

3 changes: 3 additions & 0 deletions lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## /lib

Contains javascript extensions for the generated NodeGit modules. Any additional behavior on top of the standard libgit2 behavior will be found here.
5 changes: 5 additions & 0 deletions lifecycleScripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## /lifecycleScripts

These scripts are responsible for downloading the right dependencies, configuring vendors, and all other dependencies that are required to build, generate, and clean the module.


17 changes: 17 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## /test

Contains all the test scripts, runner, and keys for running the tests.

-----------

#### /home
Contains gitconfig for the test repositories.

#### /repos
Contains blame, empty, nonrepo, and workdir test repositories.

#### /tests
Unit tests for NodeGit.

#### /utils
Test utilities with garbage collector, index, and repository setup, that can be used in tests.
6 changes: 6 additions & 0 deletions utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## /utils

Contains utilities for NodeGit

#### buildFlags
Determines how NodeGit should build. Use `BUILD_ONLY` environment variable to build from source.