Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+126
View File
@@ -0,0 +1,126 @@
on:
push:
branches:
- master
- backport/*
tags:
- v*.*.*
pull_request:
name: Testing
jobs:
nix-tests:
name: "*nix Tests"
strategy:
matrix:
node: [10, 12, 14]
os: [ubuntu-16.04, macOS-10.15]
runs-on: ${{ matrix.os }}
steps:
- name: Setup Environment
run: |
mkdir ~/.ssh_tests
chmod 700 ~/.ssh_tests
echo -e "Host *\n\tStrictHostKeyChecking no\n" > ~/.ssh_tests/config
echo -e "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBkHMoNRRkHYNE7EnQLdFxMgVcqGgNPYDhrWiLMlYuzpmEcUnhwW3zNaIa4J2JlGkRNgYZVia1Ic1V3koJPE3YO2+exAfJBIPeb6O1qDADc2hFFHzd28wmHKUkO61yzo2ZjDQfaEVtjN39Yiy19AbddN3bzNrgvuQT574fa6Rghl2RfecKYO77iHA1RGXIFc8heXVIUuUV/jHjb56WqoHH8vyt1DqUz89oyiHq8Cku0qzKN80COheZPseA1EvT0zlIgbXBxwijN4xRmvInK0fB5Kc9r3kddH2tT7V09bOFJsvGQaQmQ1WFTCqjpBFw1CHKcbfPLOxbLpVIR9gyx03R" > ~/.ssh_tests/id_rsa.pub
echo -e "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIBAAKCAQEAwZBzKDUUZB2DROxJ0C3RcTIFXKhoDT2A4a1oizJWLs6ZhHFJ\n4cFt8zWiGuCdiZRpETYGGVYmtSHNVd5KCTxN2DtvnsQHyQSD3m+jtagwA3NoRRR8\n3dvMJhylJDutcs6NmYw0H2hFbYzd/WIstfQG3XTd28za4L7kE+e+H2ukYIZdkX3n\nCmDu+4hwNURlyBXPIXl1SFLlFf4x42+elqqBx/L8rdQ6lM/PaMoh6vApLtKsyjfN\nAjoXmT7HgNRL09M5SIG1wccIozeMUZryJytHweSnPa95HXR9rU+1dPWzhSbLxkGk\nJkNVhUwqo6QRcNQhynG3zyzsWy6VSEfYMsdN0QIDAQABAoIBABsZNPYBEFy/wPvq\nNJ8/et3lCdkh/oc0ABIYK9Wo82XUKKvhDF3drZ3p+UrX/VYgf+EX9hyf8gVTuSJ3\nX1gRqDhIgeTxPsHGrwt6B6pL5ITnKEbbimuo9Ni1E+2RqUO0ZSCE/1sSRv4CRaXO\nk8HZawif7ttxv4bNUrLys6xEbpvQlOMzgs4s/OBB/XMEqnFRGPJeeTy8bkOWyTwl\nLj06nq2brs4qK4eijI/MoGy1CD8JCpL4gG39GPTXd8GpudXmdelDn1E0t9nhL6Se\naOMaiPhy7kBJD4wZ//WZTSR1XyjNBH3DGkNZxPIWcX+wJFyNoLbSbVSda/7Dtvp3\nCPfiNhECgYEA/+3JswSzcVEANNF5OLZ76x+TODkZ9T6YF4SR8/uJjNViWgUpX7vw\nmyXF+2AwzNaotbBKmNG619BcUeMmQB76c+UiMLeJuJcT/Jj0xmEUopHonGqEIcvg\nHg6cafE1is7d+l669bfjitlx+3muF2CYnylSN1LWHxIITVUj3BmcWqUCgYEAwZ45\nWdaHfK7G6GjI7liDQT4ZlslA8dmLv2Jl2ExBBMoY3m3Sre428z2ZFa4O/nsBYP0a\nDxgYmX20fQGcbPugKdCYHc7HkKbMU1GwiVCGpDYZCm2gJKTvam3dYNaiAfq5DyhP\nzDCZNJ5rrSMprXsuRv2O4c5u8qtJ5ByaOJBjOr0CgYBMlkAxzkpUssS5CaaZDiLv\nLbfEr3HRLjYdc5KpzLBQ8NpJzhmfiIJsK1Wf8B0qb2J1XJg2Oy0KwFOgPbWIoryY\nSg19Pq98Cdn1UWCOrSabr8ZIaKe55WTgGcc8/O3k6BsNfaO9PJZfSssNUlCCtml1\n18u+uo9RJPhPDBd7Gj7r8QKBgFraxWy7t24xkZMDgK4fiM/3tQhFvhz/CY2wPbxG\n5Ae8UfkmLcOCUfTIReqfd9fAnsAFZNIKa5izHRu/wsh9NwYIJSlvm8PsEVtTrPRy\nfgvWet+i24/2eYZGsag8b19gaLCNKQzXDT1czYg8RNVsRSX427BoLzXeXNkW9uNu\nFbI9AoGAV2kxcdcKS4BtNHKPeGgV87dM0DWhQaAtEXEIcQquFtba0lAXioGHg8U4\nzeiugl4Qzchwk5qd3wnZ4SOhx0s16/5gQDlnkbjFR6EREUnvLRwV92zBXUTOGIkh\nZ7Z4rcgUKlVAaHT3OHN/lTyqJG/ib+K4wZhbztl/ox+JUFsvD98=\n-----END RSA PRIVATE KEY-----" > ~/.ssh_tests/id_rsa
chmod 600 ~/.ssh_tests/id_rsa*
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- uses: actions/checkout@master
- name: Use Node.js
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node }}
- name: Install Dependencies for Ubuntu
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt install build-essential libssl-dev libkrb5-dev libc++-dev
- name: Install
env:
CC: clang
CXX: clang++
npm_config_clang: 1
GYP_DEFINES: use_obsolete_asm=true
# There is a race condition in node/generate that needs to be fixed
run: node utils/retry npm install
- name: Test
run: |
set -e
eval `ssh-agent -s`
ssh-add ~/.ssh_tests/id_rsa
node utils/retry npm test
- name: Deploy
if: startsWith(github.ref, 'refs/tags/v')
env:
node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }}
node_pre_gyp_accessKeyId: ${{ secrets.node_pre_gyp_accessKeyId }}
node_pre_gyp_secretAccessKey: ${{ secrets.node_pre_gyp_secretAccessKey }}
run: |
npm install -g node-pre-gyp aws-sdk
node lifecycleScripts/clean
node-pre-gyp package
node-pre-gyp publish
windows-tests:
name: Windows Tests
strategy:
matrix:
node: [10, 12, 14]
arch: [x86, x64]
runs-on: windows-2016
steps:
- name: Setup Environment
run: |
git config --file C:\ProgramData\Git\config core.autocrlf input
git config --system core.autocrlf input
git config --global core.autocrlf input
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
- uses: actions/checkout@master
- name: Use Node.js
uses: implausible/setup-node@feature/expose-architecture-override
with:
node-version: ${{ matrix.node }}
node-arch: ${{ matrix.arch }}
- name: Install
run: npm install
- name: Test
env:
GIT_SSH: ${{ github.workspace }}\vendor\plink.exe
run: |
powershell -command "Start-Process ${{ github.workspace }}\vendor\pageant.exe ${{ github.workspace }}\vendor\private.ppk"
node utils/retry npm test
# You're probably wondering why this isn't a single `run: |` step, it certainly is for *nix,
# but it's not, because the CI runner for windows doesn't wait for each step as listed here
# and it treats each additional step past the first as an orphaned process.
- name: Deploy (Dependencies)
if: startsWith(github.ref, 'refs/tags/v')
run: npm install -g node-pre-gyp aws-sdk
- name: Deploy (Clean)
if: startsWith(github.ref, 'refs/tags/v')
run: node lifecycleScripts\clean
- name: Deploy (Package)
if: startsWith(github.ref, 'refs/tags/v')
run: node-pre-gyp package
- name: Deploy (Publish)
if: startsWith(github.ref, 'refs/tags/v')
env:
node_pre_gyp_bucket: ${{ secrets.node_pre_gyp_bucket }}
node_pre_gyp_accessKeyId: ${{ secrets.node_pre_gyp_accessKeyId }}
node_pre_gyp_secretAccessKey: ${{ secrets.node_pre_gyp_secretAccessKey }}
run: node-pre-gyp publish
+3415
View File
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
0.2.0 / 2014-11-24
===================
* Shifted to promises; asynchronous methods now provide promises.
* Lots of new methods exposed for merging, pushing, blaming and more.
* SSH transport now works.
* Switched generation of native module code from ejsg to Combyne.
* Added continuous integration with Linux, OSX, and Windows.
* Many method and property names have changed.
+19
View File
@@ -0,0 +1,19 @@
Copyright (c) 2014 Tim Branyen
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+189
View File
@@ -0,0 +1,189 @@
# NodeGit
> Node bindings to the [libgit2](http://libgit2.github.com/) project.
[![Actions Status](https://github.com/nodegit/nodegit/workflows/Testing/badge.svg)](https://github.com/nodegit/nodegit/actions)
**Stable (libgit2@v0.28.3): 0.28.3**
## Have a problem? Come chat with us! ##
Visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up, then join us in #nodegit.
## Maintained by ##
Tyler Ang-Wanek [@twwanek](http://twitter.com/twwanek) with help from tons of
[awesome contributors](https://github.com/nodegit/nodegit/contributors)!
### Alumni Maintainers ###
Tim Branyen [@tbranyen](http://twitter.com/tbranyen),
John Haley [@johnhaley81](http://twitter.com/johnhaley81),
Max Korp [@maxkorp](http://twitter.com/MaximilianoKorp),
Steve Smith [@orderedlist](https://twitter.com/orderedlist),
Michael Robinson [@codeofinterest](http://twitter.com/codeofinterest), and
Nick Kallen [@nk](http://twitter.com/nk)
## API Documentation. ##
[http://www.nodegit.org/](http://www.nodegit.org/)
## Getting started. ##
NodeGit will work on most systems out-of-the-box without any native
dependencies.
``` bash
npm install nodegit
```
If you receive errors about libstdc++, which are commonly experienced when
building on Travis-CI, you can fix this by upgrading to the latest
libstdc++-4.9.
In Ubuntu:
``` sh
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-dev
```
In Travis:
``` yaml
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-4.9-dev
```
In CircleCI:
``` yaml
dependencies:
pre:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install -y libstdc++-4.9-dev
```
If you receive errors about *lifecycleScripts* preinstall/install you probably miss *libssl-dev*
In Ubuntu:
```
sudo apt-get install libssl-dev
```
You will need the following libraries installed on your linux machine:
- libpcre
- libpcreposix
- libkrb5
- libk5crypto
- libcom_err
When building locally, you will also need development packages for kerberos and pcre, so both of these utilities must be present on your machine:
- pcre-config
- krb5-config
If you are still encountering problems while installing, you should try the
[Building from source](http://www.nodegit.org/guides/install/from-source/)
instructions.
## API examples. ##
### Cloning a repository and reading a file: ###
``` javascript
var Git = require("nodegit");
// Clone a given repository into the `./tmp` folder.
Git.Clone("https://github.com/nodegit/nodegit", "./tmp")
// Look up this known commit.
.then(function(repo) {
// Use a known commit sha from this repository.
return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
})
// Look up a specific file within that commit.
.then(function(commit) {
return commit.getEntry("README.md");
})
// Get the blob contents from the file.
.then(function(entry) {
// Patch the blob to contain a reference to the entry.
return entry.getBlob().then(function(blob) {
blob.entry = entry;
return blob;
});
})
// Display information about the blob.
.then(function(blob) {
// Show the path, sha, and filesize in bytes.
console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + "b");
// Show a spacer.
console.log(Array(72).join("=") + "\n\n");
// Show the entire file.
console.log(String(blob));
})
.catch(function(err) { console.log(err); });
```
### Emulating git log: ###
``` javascript
var Git = require("nodegit");
// Open the repository directory.
Git.Repository.open("tmp")
// Open the master branch.
.then(function(repo) {
return repo.getMasterCommit();
})
// Display information about commits on master.
.then(function(firstCommitOnMaster) {
// Create a new history event emitter.
var history = firstCommitOnMaster.history();
// Create a counter to only show up to 9 entries.
var count = 0;
// Listen for commit events from the history.
history.on("commit", function(commit) {
// Disregard commits past 9.
if (++count >= 9) {
return;
}
// Show the commit sha.
console.log("commit " + commit.sha());
// Store the author object.
var author = commit.author();
// Display author information.
console.log("Author:\t" + author.name() + " <" + author.email() + ">");
// Show the commit date.
console.log("Date:\t" + commit.date());
// Give some space and show the message.
console.log("\n " + commit.message());
});
// Start emitting events.
history.start();
});
```
For more examples, check the `examples/` folder.
## Unit tests. ##
You will need to build locally before running the tests. See above.
``` bash
npm test
```
+325
View File
@@ -0,0 +1,325 @@
# This is a generated file, modify: generate/templates/templates/binding.gyp
{
"variables": {
"is_electron%": "<!(node ./utils/isBuildingForElectron.js <(node_root_dir))",
"is_IBMi%": "<!(node -p \"os.platform() == 'aix' && os.type() == 'OS400' ? 1 : 0\")"
},
"targets": [{
"target_name": "acquireOpenSSL",
"conditions": [
["<(is_electron) == 1 and OS != 'linux'", {
"actions": [{
"action_name": "acquire",
"action": ["node", "utils/acquireOpenSSL.js"],
"inputs": ["vendor/static_config/openssl_distributions.json"],
"outputs": ["vendor/openssl"],
"message": "Acquiring OpensSL binaries and headers"
}]
}]
]
}, {
"target_name": "configureLibssh2",
"actions": [{
"action_name": "configure",
"action": ["node", "utils/configureLibssh2.js"],
"inputs": [""],
"outputs": [""]
}],
"hard_dependencies": [
"acquireOpenSSL"
]
}, {
"target_name": "nodegit",
"hard_dependencies": [
"configureLibssh2"
],
"dependencies": [
"vendor/libgit2.gyp:libgit2"
],
"variables": {
"coverage%": 0
},
"sources": [
"src/async_baton.cc",
"src/lock_master.cc",
"src/reference_counter.cc",
"src/nodegit.cc",
"src/init_ssh2.cc",
"src/promise_completion.cc",
"src/wrapper.cc",
"src/functions/copy.cc",
"src/functions/free.cc",
"src/convenient_patch.cc",
"src/convenient_hunk.cc",
"src/filter_registry.cc",
"src/git_buf_converter.cc",
"src/str_array_converter.cc",
"src/thread_pool.cc",
"src/annotated_commit.cc",
"src/apply.cc",
"src/apply_options.cc",
"src/apply_options.cc",
"src/attr.cc",
"src/blame.cc",
"src/blame_hunk.cc",
"src/blame_options.cc",
"src/blob.cc",
"src/blob_filter_options.cc",
"src/blob_filter_options.cc",
"src/branch.cc",
"src/branch_iterator.cc",
"src/buf.cc",
"src/cert.cc",
"src/cert_hostkey.cc",
"src/cert_x509.cc",
"src/checkout.cc",
"src/checkout_options.cc",
"src/checkout_perfdata.cc",
"src/cherrypick.cc",
"src/cherrypick_options.cc",
"src/clone.cc",
"src/clone_options.cc",
"src/commit.cc",
"src/config.cc",
"src/config_entry.cc",
"src/config_entry.cc",
"src/config_iterator.cc",
"src/configmap.cc",
"src/cred.cc",
"src/describe_format_options.cc",
"src/describe_format_options.cc",
"src/describe_options.cc",
"src/describe_options.cc",
"src/describe_result.cc",
"src/diff.cc",
"src/diff_binary.cc",
"src/diff_binary_file.cc",
"src/diff_delta.cc",
"src/diff_file.cc",
"src/diff_find_options.cc",
"src/diff_hunk.cc",
"src/diff_line.cc",
"src/diff_options.cc",
"src/diff_patchid_options.cc",
"src/diff_perfdata.cc",
"src/diff_stats.cc",
"src/error.cc",
"src/fetch.cc",
"src/fetch_options.cc",
"src/fetch_options.cc",
"src/filter.cc",
"src/filter.cc",
"src/filter_list.cc",
"src/filter_source.cc",
"src/graph.cc",
"src/hashsig.cc",
"src/ignore.cc",
"src/index.cc",
"src/index_conflict_iterator.cc",
"src/index_entry.cc",
"src/index_iterator.cc",
"src/index_name_entry.cc",
"src/index_reuc_entry.cc",
"src/index_time.cc",
"src/indexer_progress.cc",
"src/libgit2.cc",
"src/mailmap.cc",
"src/merge.cc",
"src/merge_file_input.cc",
"src/merge_file_options.cc",
"src/merge_options.cc",
"src/note.cc",
"src/note_iterator.cc",
"src/object.cc",
"src/odb.cc",
"src/odb_object.cc",
"src/oid.cc",
"src/oid_shorten.cc",
"src/oidarray.cc",
"src/packbuilder.cc",
"src/patch.cc",
"src/path.cc",
"src/pathspec.cc",
"src/pathspec_match_list.cc",
"src/proxy.cc",
"src/proxy_options.cc",
"src/push_options.cc",
"src/push_update.cc",
"src/rebase.cc",
"src/rebase_operation.cc",
"src/rebase_options.cc",
"src/rebase_options.cc",
"src/refdb.cc",
"src/reference.cc",
"src/reflog.cc",
"src/reflog_entry.cc",
"src/refspec.cc",
"src/remote.cc",
"src/remote_callbacks.cc",
"src/remote_callbacks.cc",
"src/remote_create_options.cc",
"src/remote_create_options.cc",
"src/remote_head.cc",
"src/remote_head.cc",
"src/repository.cc",
"src/repository_init_options.cc",
"src/reset.cc",
"src/revert.cc",
"src/revert_options.cc",
"src/revparse.cc",
"src/revwalk.cc",
"src/signature.cc",
"src/stash.cc",
"src/stash_apply_options.cc",
"src/stash_apply_options.cc",
"src/status.cc",
"src/status_entry.cc",
"src/status_list.cc",
"src/status_options.cc",
"src/status_options.cc",
"src/strarray.cc",
"src/submodule.cc",
"src/submodule_update_options.cc",
"src/tag.cc",
"src/time.cc",
"src/trace.cc",
"src/transaction.cc",
"src/transport.cc",
"src/tree.cc",
"src/tree_entry.cc",
"src/tree_update.cc",
"src/treebuilder.cc",
"src/worktree.cc",
"src/worktree_add_options.cc",
"src/worktree_add_options.cc",
"src/worktree_prune_options.cc",
"src/worktree_prune_options.cc",
"src/writestream.cc",
],
"include_dirs": [
"vendor/libv8-convert",
"vendor/libssh2/include",
"<!(node -e \"require('nan')\")"
],
"cflags": [
"-Wall"
],
"conditions": [
[
"coverage==1", {
"cflags": [
"-ftest-coverage",
"-fprofile-arcs"
],
"link_settings": {
"libraries": [
"-lgcov"
]
},
}
],
[
"OS=='mac'", {
"libraries": [
"-liconv",
],
"conditions": [
["<(is_electron) == 1", {
"include_dirs": [
"vendor/openssl/include"
],
"libraries": [
"<(module_root_dir)/vendor/openssl/lib/libcrypto.a",
"<(module_root_dir)/vendor/openssl/lib/libssl.a"
]
}]
],
"xcode_settings": {
"GCC_ENABLE_CPP_EXCEPTIONS": "YES",
"MACOSX_DEPLOYMENT_TARGET": "10.9",
'CLANG_CXX_LIBRARY': 'libc++',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',
"WARNING_CFLAGS": [
"-Wno-unused-variable",
"-Wint-conversions",
"-Wmissing-field-initializers",
"-Wno-c++11-extensions"
]
}
}
],
[
"OS=='win'", {
"conditions": [
["<(is_electron) == 1", {
"include_dirs": ["vendor/openssl/include"],
"libraries": [
"<(module_root_dir)/vendor/openssl/lib/libcrypto.lib",
"<(module_root_dir)/vendor/openssl/lib/libssl.lib"
]
}]
],
"defines": [
"_HAS_EXCEPTIONS=1"
],
"msvs_settings": {
"VCCLCompilerTool": {
"AdditionalOptions": [
"/EHsc"
]
},
"VCLinkerTool": {
"AdditionalOptions": [
"/FORCE:MULTIPLE"
]
}
},
"libraries": [
"winhttp.lib",
"crypt32.lib",
"rpcrt4.lib"
]
}
],
["OS=='mac' or OS=='linux' or OS.endswith('bsd') or <(is_IBMi) == 1", {
"libraries": [
"<!(krb5-config gssapi --libs)"
]
}],
[
"OS=='linux' or OS.endswith('bsd') or <(is_IBMi) == 1", {
"cflags": [
"-std=c++11"
]
}
],
[
"OS.endswith('bsd') or (<(is_electron) == 1 and OS=='linux') or <(is_IBMi) == 1", {
"libraries": [
"-lcrypto",
"-lssl"
],
}
],
[
"<(is_IBMi) == 1", {
"include_dirs": [
"/QOpenSys/pkgs/include"
],
"libraries": [
"-L/QOpenSys/pkgs/lib"
]
}
]
]
}]
}
+21
View File
@@ -0,0 +1,21 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
NodeGit.Attr.STATES = {};
var DEPRECATED_STATES = {
UNSPECIFIED_T: "UNSPECIFIED",
TRUE_T: "TRUE",
FALSE_T: "FALSE",
VALUE_T: "STRING"
};
Object.keys(DEPRECATED_STATES).forEach(function (key) {
var newKey = DEPRECATED_STATES[key];
Object.defineProperty(NodeGit.Attr.STATES, key, {
get: util.deprecate(function () {
return NodeGit.Attr.VALUE[newKey];
}, "Use NodeGit.Attr.VALUE." + newKey + " instead of NodeGit.Attr.STATES." + key + ".")
});
});
+22
View File
@@ -0,0 +1,22 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Blame = NodeGit.Blame;
var _file = Blame.file;
/**
* Retrieve the blame of a file
*
* @async
* @param {Repository} repo that contains the file
* @param {String} path to the file to get the blame of
* @param {BlameOptions} [options] Options for the blame
* @return {Blame} the blame
*/
Blame.file = function (repo, path, options) {
options = normalizeOptions(options, NodeGit.BlameOptions);
return _file.call(this, repo, path, options);
};
+71
View File
@@ -0,0 +1,71 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var Blob = NodeGit.Blob;
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var TreeEntry = NodeGit.TreeEntry;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var _filteredContent = Blob.filteredContent;
var _filter = Blob.prototype.filter;
/**
* Retrieves the blob pointed to by the oid
* @async
* @param {Repository} repo The repo that the blob lives in
* @param {String|Oid|Blob} id The blob to lookup
* @return {Blob}
*/
Blob.lookup = LookupWrapper(Blob);
/**
* Retrieve the content of the Blob.
*
* @return {Buffer} Contents as a buffer.
*/
Blob.prototype.content = function () {
return this.rawcontent().toBuffer(this.rawsize());
};
/**
* Retrieve the Blob's type.
*
* @return {Number} The filemode of the blob.
*/
Blob.prototype.filemode = function () {
var FileMode = TreeEntry.FILEMODE;
return this.isBinary() ? FileMode.EXECUTABLE : FileMode.BLOB;
};
/**
* Retrieve the Blob's content as String.
*
* @return {String} Contents as a string.
*/
Blob.prototype.toString = function () {
return this.content().toString();
};
/**
* Get a buffer with the filtered content of a blob.
*
* This applies filters as if the blob was being checked out to the
* working directory under the specified filename. This may apply
* CRLF filtering or other types of changes depending on the file
* attributes set for the blob and the content detected in it.
*
* @async
* @param asPath Path used for file attribute lookups, etc.
* @param opts Options to use for filtering the blob
* @return {Promise<string>}
*/
Blob.prototype.filter = function (asPath, opts) {
if (opts) {
opts = normalizeOptions(opts, NodeGit.BlobFilterOptions);
}
return _filter.call(this, asPath, opts);
};
Blob.filteredContent = util.deprecate(_filteredContent, "NodeGit.Blob.filteredContent is deprecated" + "use NodeGit.Blob.prototype.filter instead.");
+20
View File
@@ -0,0 +1,20 @@
"use strict";
var NodeGit = require("../");
var Branch = NodeGit.Branch;
var _remoteName = Branch.remoteName;
/**
* Retrieve the Branch's Remote Name as a String.
*
* @async
* @param {Repository} repo The repo to get the remote name from
* @param {String} the refname of the branch
* @return {String} remote name as a string.
*/
Branch.remoteName = function (repo, remoteRef) {
return _remoteName.call(this, repo, remoteRef).then(function (remoteNameBuffer) {
return remoteNameBuffer.toString();
});
};
+16
View File
@@ -0,0 +1,16 @@
"use strict";
var _require = require("../"),
Buf = _require.Buf;
/**
* Sets the content of a GitBuf to a string.
* @param {string} The utf8 value to set in the buffer.
* The string will be null terminated.
*/
Buf.prototype.setString = function (content) {
var buf = Buffer.from(content + "\0", "utf8");
this.set(buf, buf.length);
};
+53
View File
@@ -0,0 +1,53 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Checkout = NodeGit.Checkout;
var _head = Checkout.head;
var _index = Checkout.index;
var _tree = Checkout.tree;
/**
* Patch head checkout to automatically coerce objects.
*
* @async
* @param {Repository} repo The repo to checkout head
* @param {CheckoutOptions} [options] Options for the checkout
* @return {Void} checkout complete
*/
Checkout.head = function (url, options) {
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
return _head.call(this, url, options);
};
/**
* Patch index checkout to automatically coerce objects.
*
* @async
* @param {Repository} repo The repo to checkout an index
* @param {Index} index The index to checkout
* @param {CheckoutOptions} [options] Options for the checkout
* @return {Void} checkout complete
*/
Checkout.index = function (repo, index, options) {
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
return _index.call(this, repo, index, options);
};
/**
* Patch tree checkout to automatically coerce objects.
*
* @async
* @param {Repository} repo
* @param {String|Tree|Commit|Reference} treeish
* @param {CheckoutOptions} [options]
* @return {Void} checkout complete
*/
Checkout.tree = function (repo, treeish, options) {
options = normalizeOptions(options || {}, NodeGit.CheckoutOptions);
return _tree.call(this, repo, treeish, options);
};
+62
View File
@@ -0,0 +1,62 @@
"use strict";
var NodeGit = require("../");
var shallowClone = NodeGit.Utils.shallowClone;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Cherrypick = NodeGit.Cherrypick;
var _cherrypick = Cherrypick.cherrypick;
var _commit = Cherrypick.commit;
/**
* Cherrypick a commit and, changing the index and working directory
*
* @async
* @param {Repository} repo The repo to checkout head
* @param {Commit} commit The commit to cherrypick
* @param {CherrypickOptions} [options] Options for the cherrypick
* @return {int} 0 on success, -1 on failure
*/
Cherrypick.cherrypick = function (repo, commit, options) {
var mergeOpts;
var checkoutOpts;
if (options) {
options = shallowClone(options);
mergeOpts = options.mergeOpts;
checkoutOpts = options.checkoutOpts;
delete options.mergeOpts;
delete options.checkoutOpts;
}
options = normalizeOptions(options, NodeGit.CherrypickOptions);
if (mergeOpts) {
options.mergeOpts = normalizeOptions(mergeOpts, NodeGit.MergeOptions);
}
if (checkoutOpts) {
options.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions);
}
return _cherrypick.call(this, repo, commit, options);
};
/**
* Cherrypicks the given commit against "our" commit, producing an index that
* reflects the result of the cherrypick. The index is not backed by a repo.
*
* @async
* @param {Repository} repo The repo to cherrypick commits
* @param {Commit} cherrypick_commit The commit to cherrypick
* @param {Commit} our_commit The commit to revert against
* @param {int} mainline The parent of the revert commit (1 or
* 2) if it's a merge, 0 otherwise
* @param {MergeOptions} [merge_options] Merge options for the cherrypick
* @return {int} 0 on success, -1 on failure
*/
Cherrypick.commit = function (repo, cherrypick_commit, our_commit, mainline, merge_options) {
merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions);
return _commit.call(this, repo, cherrypick_commit, our_commit, mainline, merge_options);
};
+35
View File
@@ -0,0 +1,35 @@
"use strict";
var NodeGit = require("../");
var shallowClone = NodeGit.Utils.shallowClone;
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Clone = NodeGit.Clone;
var _clone = Clone.clone;
/**
* Patch repository cloning to automatically coerce objects.
*
* @async
* @param {String} url url of the repository
* @param {String} local_path local path to store repository
* @param {CloneOptions} [options]
* @return {Repository} repo
*/
Clone.clone = function (url, local_path, options) {
var fetchOpts = normalizeFetchOptions(options && options.fetchOpts);
if (options) {
options = shallowClone(options);
delete options.fetchOpts;
}
options = normalizeOptions(options, NodeGit.CloneOptions);
if (options) {
options.fetchOpts = fetchOpts;
}
return _clone.call(this, url, local_path, options);
};
+387
View File
@@ -0,0 +1,387 @@
"use strict";
var events = require("events");
var fp = require("lodash/fp");
var NodeGit = require("../");
var Commit = NodeGit.Commit;
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var _amend = Commit.prototype.amend;
var _parent = Commit.prototype.parent;
/**
* Retrieves the commit pointed to by the oid
* @async
* @param {Repository} repo The repo that the commit lives in
* @param {String|Oid|Commit} id The commit to lookup
* @return {Commit}
*/
Commit.lookup = LookupWrapper(Commit);
/**
* @async
* @param {Number} n
* @return {Commit}
*/
Commit.prototype.parent = function (n) {
var repo = this.repo;
return _parent.call(this, n).then(function (p) {
p.repo = repo;
return p;
});
};
/**
* Amend a commit
* @async
* @param {String} update_ref
* @param {Signature} author
* @param {Signature} committer
* @param {String} message_encoding
* @param {String} message
* @param {Tree|Oid} tree
* @return {Oid}
*/
Commit.prototype.amend = function (updateRef, author, committer, message_encoding, message, tree) {
var repo = this.repo;
var _this = this;
var treePromise;
if (tree instanceof NodeGit.Oid) {
treePromise = repo.getTree(tree);
} else {
treePromise = Promise.resolve(tree);
}
return treePromise.then(function (treeObject) {
return _amend.call(_this, updateRef, author, committer, message_encoding, message, treeObject);
});
};
/**
* Amend a commit with the given signature
* @async
* @param {String} updateRef
* @param {Signature} author
* @param {Signature} committer
* @param {String} messageEncoding
* @param {String} message
* @param {Tree|Oid} tree
* @param {Function} onSignature Callback to be called with string to be signed
* @return {Oid}
*/
Commit.prototype.amendWithSignature = function (updateRef, author, committer, messageEncoding, message, tree, onSignature) {
var repo = this.repo;
var parentOids = this.parents();
var _this = this;
var promises = [];
if (tree instanceof NodeGit.Oid) {
promises.push(repo.getTree(tree));
} else {
promises.push(Promise.resolve(tree));
}
parentOids.forEach(function (parentOid) {
promises.push(repo.getCommit(parentOid));
});
var treeObject = void 0;
var parents = void 0;
var commitContent = void 0;
var commit = void 0;
var skippedSigning = void 0;
var resolvedAuthor = void 0;
var resolvedCommitter = void 0;
var resolvedMessageEncoding = void 0;
var resolvedMessage = void 0;
var resolvedTree = void 0;
var createCommitPromise = Promise.all(promises).then(function (results) {
treeObject = fp.head(results);
parents = fp.tail(results);
return _this.getTree();
}).then(function (commitTreeResult) {
var commitTree = commitTreeResult;
var truthyArgs = fp.omitBy(fp.isNil, {
author: author,
committer: committer,
messageEncoding: messageEncoding,
message: message,
tree: treeObject
});
var commitFields = {
author: _this.author(),
committer: _this.committer(),
messageEncoding: _this.messageEncoding(),
message: _this.message(),
tree: commitTree
};
var _fp$assign = fp.assign(commitFields, truthyArgs);
resolvedAuthor = _fp$assign.author;
resolvedCommitter = _fp$assign.committer;
resolvedMessageEncoding = _fp$assign.messageEncoding;
resolvedMessage = _fp$assign.message;
resolvedTree = _fp$assign.tree;
return Commit.createBuffer(repo, resolvedAuthor, resolvedCommitter, resolvedMessageEncoding, resolvedMessage, resolvedTree, parents.length, parents);
}).then(function (commitContentResult) {
commitContent = commitContentResult;
if (!commitContent.endsWith("\n")) {
commitContent += "\n";
}
return onSignature(commitContent);
}).then(function (_ref) {
var code = _ref.code,
field = _ref.field,
signedData = _ref.signedData;
switch (code) {
case NodeGit.Error.CODE.OK:
return Commit.createWithSignature(repo, commitContent, signedData, field);
case NodeGit.Error.CODE.PASSTHROUGH:
skippedSigning = true;
return Commit.create(repo, updateRef, resolvedAuthor, resolvedCommitter, resolvedMessageEncoding, resolvedMessage, resolvedTree, parents.length, parents);
default:
{
var error = new Error("Commit.amendWithSignature threw with error code " + code);
error.errno = code;
throw error;
}
}
});
if (!updateRef) {
return createCommitPromise;
}
return createCommitPromise.then(function (commitOid) {
if (skippedSigning) {
return commitOid;
}
return repo.getCommit(commitOid).then(function (commitResult) {
commit = commitResult;
return repo.getReference(updateRef);
}).then(function (ref) {
return ref.setTarget(commitOid, "commit (amend): " + commit.summary());
}).then(function () {
return commitOid;
});
});
};
/**
* Retrieve the commit time as a Date object.
* @return {Date}
*/
Commit.prototype.date = function () {
return new Date(this.timeMs());
};
/**
* Generate an array of diff trees showing changes between this commit
* and its parent(s).
*
* @async
* @return {Array<Diff>} an array of diffs
*/
Commit.prototype.getDiff = function () {
return this.getDiffWithOptions(null);
};
/**
* Generate an array of diff trees showing changes between this commit
* and its parent(s).
*
* @async
* @param {Object} options
* @return {Array<Diff>} an array of diffs
*/
Commit.prototype.getDiffWithOptions = function (options) {
var commit = this;
return commit.getTree().then(function (thisTree) {
return commit.getParents().then(function (parents) {
var diffs;
if (parents.length) {
diffs = parents.map(function (parent) {
return parent.getTree().then(function (parentTree) {
return thisTree.diffWithOptions(parentTree, options);
});
});
} else {
diffs = [thisTree.diffWithOptions(null, options)];
}
return Promise.all(diffs);
});
});
};
/**
* Retrieve the entry represented by path for this commit.
* Path must be relative to repository root.
*
* @async
* @param {String} path
* @return {TreeEntry}
*/
Commit.prototype.getEntry = function (path) {
return this.getTree().then(function (tree) {
return tree.getEntry(path);
});
};
/**
* Retrieve the commit's parents as commit objects.
*
* @async
* @param {number} limit Optional amount of parents to return.
* @return {Array<Commit>} array of commits
*/
Commit.prototype.getParents = function (limit) {
var parents = [];
// If no limit was set, default to the maximum parents.
limit = typeof limit === "number" ? limit : this.parentcount();
limit = Math.min(limit, this.parentcount());
for (var i = 0; i < limit; i++) {
var oid = this.parentId(i);
var parent = this.repo.getCommit(oid);
parents.push(parent);
}
// Wait for all parents to complete, before returning.
return Promise.all(parents);
};
/**
* @typedef extractedSignature
* @type {Object}
* @property {String} signature the signature of the commit
* @property {String} signedData the extracted signed data
*/
/**
* Retrieve the signature and signed data for a commit.
* @param {String} field Optional field to get from the signature,
* defaults to gpgsig
* @return {extractedSignature}
*/
Commit.prototype.getSignature = function (field) {
return Commit.extractSignature(this.repo, this.id(), field);
};
/**
* Get the tree associated with this commit.
*
* @async
* @return {Tree}
*/
Commit.prototype.getTree = function () {
return this.repo.getTree(this.treeId());
};
/**
* Walk the history from this commit backwards.
*
* An EventEmitter is returned that will emit a "commit" event for each
* commit in the history, and one "end" event when the walk is completed.
* Don't forget to call `start()` on the returned event.
*
* @fires EventEmitter#commit Commit
* @fires EventEmitter#end Array<Commit>
* @fires EventEmitter#error Error
*
* @return {EventEmitter}
* @start start()
*/
Commit.prototype.history = function () {
var event = new events.EventEmitter();
var oid = this.id();
var revwalk = this.repo.createRevWalk();
revwalk.sorting.apply(revwalk, arguments);
var commits = [];
event.start = function () {
revwalk.walk(oid, function commitRevWalk(error, commit) {
if (error) {
if (error.errno === NodeGit.Error.CODE.ITEROVER) {
event.emit("end", commits);
return;
} else {
return event.emit("error", error);
}
}
event.emit("commit", commit);
commits.push(commit);
});
};
return event;
};
/**
* Get the specified parent of the commit.
*
* @param {number} the position of the parent, starting from 0
* @async
* @return {Commit} the parent commit at the specified position
*/
Commit.prototype.parent = function (id) {
var repository = this.repo;
return _parent.call(this, id).then(function (parent) {
parent.repo = repository;
return parent;
});
};
/**
* Retrieve the commit's parent shas.
*
* @return {Array<Oid>} array of oids
*/
Commit.prototype.parents = function () {
var result = [];
for (var i = 0; i < this.parentcount(); i++) {
result.push(this.parentId(i));
}
return result;
};
/**
* Retrieve the SHA.
* @return {String}
*/
Commit.prototype.sha = function () {
return this.id().toString();
};
/**
* Retrieve the commit time as a unix timestamp.
* @return {Number}
*/
Commit.prototype.timeMs = function () {
return this.time() * 1000;
};
/**
* The sha of this commit
* @return {String}
*/
Commit.prototype.toString = function () {
return this.sha();
};
+21
View File
@@ -0,0 +1,21 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var Config = NodeGit.Config;
// Backwards compatibility.
Config.prototype.getString = function () {
return this.getStringBuf.apply(this, arguments);
};
NodeGit.Enums.CVAR = {};
var DEPRECATED_CVAR_ENUMS = ["FALSE", "TRUE", "INT32", "STRING"];
DEPRECATED_CVAR_ENUMS.forEach(function (key) {
Object.defineProperty(NodeGit.Enums.CVAR, key, {
get: util.deprecate(function () {
return Config.MAP[key];
}, "Use NodeGit.Config.MAP." + key + " instead of NodeGit.Enums.CVAR." + key + ".")
});
});
+63
View File
@@ -0,0 +1,63 @@
"use strict";
var NodeGit = require("../");
var ConvenientHunk = NodeGit.ConvenientHunk;
var header = ConvenientHunk.prototype.header;
/**
* Diff header string that represents the context of this hunk
* of the diff. Something like `@@ -169,14 +167,12 @@ ...`
* @return {String}
*/
ConvenientHunk.prototype.header = header;
var headerLen = ConvenientHunk.prototype.headerLen;
/**
* The length of the header
* @return {Number}
*/
ConvenientHunk.prototype.headerLen = headerLen;
var lines = ConvenientHunk.prototype.lines;
/**
* The lines in this hunk
* @async
* @return {Array<DiffLine>}
*/
ConvenientHunk.prototype.lines = lines;
var newLines = ConvenientHunk.prototype.newLines;
/**
* The number of new lines in the hunk
* @return {Number}
*/
ConvenientHunk.prototype.newLines = newLines;
var newStart = ConvenientHunk.prototype.newStart;
/**
* The starting offset of the first new line in the file
* @return {Number}
*/
ConvenientHunk.prototype.newStart = newStart;
var oldLines = ConvenientHunk.prototype.oldLines;
/**
* The number of old lines in the hunk
* @return {Number}
*/
ConvenientHunk.prototype.oldLines = oldLines;
var oldStart = ConvenientHunk.prototype.oldStart;
/**
* The starting offset of the first old line in the file
* @return {Number}
*/
ConvenientHunk.prototype.oldStart = oldStart;
var size = ConvenientHunk.prototype.size;
/**
* Number of lines in this hunk
* @return {Number}
*/
ConvenientHunk.prototype.size = size;
+133
View File
@@ -0,0 +1,133 @@
"use strict";
var NodeGit = require("../");
var ConvenientPatch = NodeGit.ConvenientPatch;
var hunks = ConvenientPatch.prototype.hunks;
/**
* The hunks in this patch
* @async
* @return {Array<ConvenientHunk>} a promise that resolves to an array of
* ConvenientHunks
*/
ConvenientPatch.prototype.hunks = hunks;
var isAdded = ConvenientPatch.prototype.isAdded;
/**
* Is this an added patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isAdded = isAdded;
var isConflicted = ConvenientPatch.prototype.isConflicted;
/**
* Is this a conflicted patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isConflicted = isConflicted;
var isCopied = ConvenientPatch.prototype.isCopied;
/**
* Is this a copied patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isCopied = isCopied;
var isDeleted = ConvenientPatch.prototype.isDeleted;
/**
* Is this a deleted patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isDeleted = isDeleted;
var isIgnored = ConvenientPatch.prototype.isIgnored;
/**
* Is this an ignored patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isIgnored = isIgnored;
var isModified = ConvenientPatch.prototype.isModified;
/**
* Is this an modified patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isModified = isModified;
var isRenamed = ConvenientPatch.prototype.isRenamed;
/**
* Is this a renamed patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isRenamed = isRenamed;
var isTypeChange = ConvenientPatch.prototype.isTypeChange;
/**
* Is this a type change?
* @return {Boolean}
*/
ConvenientPatch.prototype.isTypeChange = isTypeChange;
var isUnmodified = ConvenientPatch.prototype.isUnmodified;
/**
* Is this an unmodified patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isUnmodified = isUnmodified;
var isUnreadable = ConvenientPatch.prototype.isUnreadable;
/**
* Is this an undreadable patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isUnreadable = isUnreadable;
var isUntracked = ConvenientPatch.prototype.isUntracked;
/**
* Is this an untracked patch?
* @return {Boolean}
*/
ConvenientPatch.prototype.isUntracked = isUntracked;
/**
* @typedef lineStats
* @type {Object}
* @property {number} total_context # of contexts in the patch
* @property {number} total_additions # of lines added in the patch
* @property {number} total_deletions # of lines deleted in the patch
*/
var lineStats = ConvenientPatch.prototype.lineStats;
/**
* The line statistics of this patch (#contexts, #added, #deleted)
* @return {lineStats}
*/
ConvenientPatch.prototype.lineStats = lineStats;
var newFile = ConvenientPatch.prototype.newFile;
/**
* New attributes of the file
* @return {DiffFile}
*/
ConvenientPatch.prototype.newFile = newFile;
var oldFile = ConvenientPatch.prototype.oldFile;
/**
* Old attributes of the file
* @return {DiffFile}
*/
ConvenientPatch.prototype.oldFile = oldFile;
var size = ConvenientPatch.prototype.size;
/**
* The number of hunks in this patch
* @return {Number}
*/
ConvenientPatch.prototype.size = size;
var status = ConvenientPatch.prototype.status;
/**
* The status of this patch (unmodified, added, deleted)
* @return {Number}
*/
ConvenientPatch.prototype.status = status;
+94
View File
@@ -0,0 +1,94 @@
"use strict";
var NodeGit = require("../");
var Diff = NodeGit.Diff;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Patch = NodeGit.Patch;
var _blobToBuffer = Diff.blobToBuffer;
var _indexToWorkdir = Diff.indexToWorkdir;
var _treeToIndex = Diff.treeToIndex;
var _treeToTree = Diff.treeToTree;
var _treeToWorkdir = Diff.treeToWorkdir;
var _treeToWorkdirWithIndex = Diff.treeToWorkdirWithIndex;
var _findSimilar = Diff.prototype.findSimilar;
/**
* Directly run a diff between a blob and a buffer.
* @async
* @param {Blob} old_blob Blob for old side of diff, or NULL for empty blob
* @param {String} old_as_path Treat old blob as if it had this filename;
* can be NULL
* @param {String} buffer Raw data for new side of diff, or NULL for empty
* @param {String} buffer_as_path Treat buffer as if it had this filename;
* can be NULL
* @param {DiffOptions} opts Options for diff, or NULL for default options
* @param {Function} file_cb Callback for "file"; made once if there is a diff;
* can be NULL
* @param {Function} binary_cb Callback for binary files; can be NULL
* @param {Function} hunk_cb Callback for each hunk in diff; can be NULL
* @param {Function} line_cb Callback for each line in diff; can be NULL
*/
Diff.blobToBuffer = function (old_blob, old_as_path, buffer, buffer_as_path, opts, file_cb, binary_cb, hunk_cb, line_cb) {
var bufferText;
var bufferLength;
if (buffer instanceof Buffer) {
bufferText = buffer.toString("utf8");
bufferLength = Buffer.byteLength(buffer, "utf8");
} else {
bufferText = buffer;
bufferLength = !buffer ? 0 : Buffer.byteLength(buffer, "utf8");
}
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _blobToBuffer.call(this, old_blob, old_as_path, bufferText, bufferLength, buffer_as_path, opts, file_cb, binary_cb, hunk_cb, line_cb, null);
};
// Override Diff.indexToWorkdir to normalize opts
Diff.indexToWorkdir = function (repo, index, opts) {
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _indexToWorkdir(repo, index, opts);
};
// Override Diff.treeToIndex to normalize opts
Diff.treeToIndex = function (repo, tree, index, opts) {
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _treeToIndex(repo, tree, index, opts);
};
// Override Diff.treeToTree to normalize opts
Diff.treeToTree = function (repo, from_tree, to_tree, opts) {
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _treeToTree(repo, from_tree, to_tree, opts);
};
// Override Diff.treeToWorkdir to normalize opts
Diff.treeToWorkdir = function (repo, tree, opts) {
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _treeToWorkdir(repo, tree, opts);
};
// Override Diff.treeToWorkdir to normalize opts
Diff.treeToWorkdirWithIndex = function (repo, tree, opts) {
opts = normalizeOptions(opts, NodeGit.DiffOptions);
return _treeToWorkdirWithIndex(repo, tree, opts);
};
// Override Diff.findSimilar to normalize opts
Diff.prototype.findSimilar = function (opts) {
opts = normalizeOptions(opts, NodeGit.DiffFindOptions);
return _findSimilar.call(this, opts);
};
/**
* Retrieve patches in this difflist
*
* @async
* @return {Array<ConvenientPatch>} a promise that resolves to an array of
* ConvenientPatches
*/
Diff.prototype.patches = function () {
return Patch.convenientFromDiff(this);
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
var NodeGit = require("../");
var DiffFile = NodeGit.DiffFile;
var flags = DiffFile.prototype.flags;
/**
* Returns the file's flags
* @return {Number}
*/
DiffFile.prototype.flags = flags;
var id = DiffFile.prototype.id;
/**
* Returns the file's Oid
* @return {Oid}
*/
DiffFile.prototype.id = id;
var mode = DiffFile.prototype.mode;
/**
* Returns the file's mode
* @return {Number}
*/
DiffFile.prototype.mode = mode;
var path = DiffFile.prototype.path;
/**
* Returns the file's path
* @return {String}
*/
DiffFile.prototype.path = path;
var size = DiffFile.prototype.size;
/**
* Returns the file's size
* @return {Number}
*/
DiffFile.prototype.size = size;
+32
View File
@@ -0,0 +1,32 @@
"use strict";
var NodeGit = require("../");
var DiffLine = NodeGit.DiffLine;
var _rawContent = DiffLine.prototype.content;
/**
* The relevant line
* @return {String}
*/
DiffLine.prototype.content = function () {
if (!this._cache) {
this._cache = {};
}
if (!this._cache.content) {
this._cache.content = new Buffer(this.rawContent()).slice(0, this.contentLen()).toString("utf8");
}
return this._cache.content;
};
/**
* The non utf8 translated text
* @return {String}
*/
DiffLine.prototype.rawContent = function () {
return _rawContent.call(this);
};
NodeGit.DiffLine = DiffLine;
+689
View File
@@ -0,0 +1,689 @@
"use strict";
// This is a generated file, modify: generate/templates/templates/enums.js
var NodeGit = require("../");
NodeGit.Enums = {};
NodeGit.Apply.FLAGS = {
CHECK: 1
};
NodeGit.Apply.LOCATION = {
WORKDIR: 0,
INDEX: 1,
BOTH: 2
};
NodeGit.Attr.VALUE = {
UNSPECIFIED: 0,
TRUE: 1,
FALSE: 2,
STRING: 3
};
NodeGit.Blame.FLAG = {
NORMAL: 0,
TRACK_COPIES_SAME_FILE: 1,
TRACK_COPIES_SAME_COMMIT_MOVES: 2,
TRACK_COPIES_SAME_COMMIT_COPIES: 4,
TRACK_COPIES_ANY_COMMIT_COPIES: 8,
FIRST_PARENT: 16,
USE_MAILMAP: 32
};
NodeGit.Blob.FILTER_FLAG = {
CHECK_FOR_BINARY: 1,
NO_SYSTEM_ATTRIBUTES: 2,
ATTTRIBUTES_FROM_HEAD: 4
};
NodeGit.Branch.BRANCH = {
LOCAL: 1,
REMOTE: 2,
ALL: 3
};
NodeGit.Cert.TYPE = {
NONE: 0,
X509: 1,
HOSTKEY_LIBSSH2: 2,
STRARRAY: 3
};
NodeGit.Cert.SSH = {
MD5: 1,
SHA1: 2,
SHA256: 4
};
NodeGit.Checkout.NOTIFY = {
NONE: 0,
CONFLICT: 1,
DIRTY: 2,
UPDATED: 4,
UNTRACKED: 8,
IGNORED: 16,
ALL: 65535
};
NodeGit.Checkout.STRATEGY = {
NONE: 0,
SAFE: 1,
FORCE: 2,
RECREATE_MISSING: 4,
ALLOW_CONFLICTS: 16,
REMOVE_UNTRACKED: 32,
REMOVE_IGNORED: 64,
UPDATE_ONLY: 128,
DONT_UPDATE_INDEX: 256,
NO_REFRESH: 512,
SKIP_UNMERGED: 1024,
USE_OURS: 2048,
USE_THEIRS: 4096,
DISABLE_PATHSPEC_MATCH: 8192,
SKIP_LOCKED_DIRECTORIES: 262144,
DONT_OVERWRITE_IGNORED: 524288,
CONFLICT_STYLE_MERGE: 1048576,
CONFLICT_STYLE_DIFF3: 2097152,
DONT_REMOVE_EXISTING: 4194304,
DONT_WRITE_INDEX: 8388608,
UPDATE_SUBMODULES: 65536,
UPDATE_SUBMODULES_IF_CHANGED: 131072
};
NodeGit.Clone.LOCAL = {
AUTO: 0,
LOCAL: 1,
NO_LOCAL: 2,
NO_LINKS: 3
};
NodeGit.Config.LEVEL = {
PROGRAMDATA: 1,
SYSTEM: 2,
XDG: 3,
GLOBAL: 4,
LOCAL: 5,
APP: 6,
HIGHEST_LEVEL: -1
};
NodeGit.Config.MAP = {
FALSE: 0,
TRUE: 1,
INT32: 2,
STRING: 3
};
NodeGit.Cred.TYPE = {
USERPASS_PLAINTEXT: 1,
SSH_KEY: 2,
SSH_CUSTOM: 4,
DEFAULT: 8,
SSH_INTERACTIVE: 16,
USERNAME: 32,
SSH_MEMORY: 64
};
NodeGit.Diff.DELTA = {
UNMODIFIED: 0,
ADDED: 1,
DELETED: 2,
MODIFIED: 3,
RENAMED: 4,
COPIED: 5,
IGNORED: 6,
UNTRACKED: 7,
TYPECHANGE: 8,
UNREADABLE: 9,
CONFLICTED: 10
};
NodeGit.DiffBinary.DIFF_BINARY = {
NONE: 0,
LITERAL: 1,
DELTA: 2
};
NodeGit.Diff.FIND = {
BY_CONFIG: 0,
RENAMES: 1,
RENAMES_FROM_REWRITES: 2,
COPIES: 4,
COPIES_FROM_UNMODIFIED: 8,
REWRITES: 16,
BREAK_REWRITES: 32,
AND_BREAK_REWRITES: 48,
FOR_UNTRACKED: 64,
ALL: 255,
IGNORE_LEADING_WHITESPACE: 0,
IGNORE_WHITESPACE: 4096,
DONT_IGNORE_WHITESPACE: 8192,
EXACT_MATCH_ONLY: 16384,
BREAK_REWRITES_FOR_RENAMES_ONLY: 32768,
REMOVE_UNMODIFIED: 65536
};
NodeGit.Diff.FLAG = {
BINARY: 1,
NOT_BINARY: 2,
VALID_ID: 4,
EXISTS: 8
};
NodeGit.Diff.FORMAT = {
PATCH: 1,
PATCH_HEADER: 2,
RAW: 3,
NAME_ONLY: 4,
NAME_STATUS: 5,
PATCH_ID: 6
};
NodeGit.Diff.FORMAT_EMAIL_FLAGS = {
FORMAT_EMAIL_NONE: 0,
FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER: 1
};
NodeGit.Diff.LINE = {
CONTEXT: 32,
ADDITION: 43,
DELETION: 45,
CONTEXT_EOFNL: 61,
ADD_EOFNL: 62,
DEL_EOFNL: 60,
FILE_HDR: 70,
HUNK_HDR: 72,
BINARY: 66
};
NodeGit.Diff.OPTION = {
NORMAL: 0,
REVERSE: 1,
INCLUDE_IGNORED: 2,
RECURSE_IGNORED_DIRS: 4,
INCLUDE_UNTRACKED: 8,
RECURSE_UNTRACKED_DIRS: 16,
INCLUDE_UNMODIFIED: 32,
INCLUDE_TYPECHANGE: 64,
INCLUDE_TYPECHANGE_TREES: 128,
IGNORE_FILEMODE: 256,
IGNORE_SUBMODULES: 512,
IGNORE_CASE: 1024,
INCLUDE_CASECHANGE: 2048,
DISABLE_PATHSPEC_MATCH: 4096,
SKIP_BINARY_CHECK: 8192,
ENABLE_FAST_UNTRACKED_DIRS: 16384,
UPDATE_INDEX: 32768,
INCLUDE_UNREADABLE: 65536,
INCLUDE_UNREADABLE_AS_UNTRACKED: 131072,
INDENT_HEURISTIC: 262144,
FORCE_TEXT: 1048576,
FORCE_BINARY: 2097152,
IGNORE_WHITESPACE: 4194304,
IGNORE_WHITESPACE_CHANGE: 8388608,
IGNORE_WHITESPACE_EOL: 16777216,
SHOW_UNTRACKED_CONTENT: 33554432,
SHOW_UNMODIFIED: 67108864,
PATIENCE: 268435456,
MINIMAL: 536870912,
SHOW_BINARY: 1073741824
};
NodeGit.Diff.STATS_FORMAT = {
STATS_NONE: 0,
STATS_FULL: 1,
STATS_SHORT: 2,
STATS_NUMBER: 4,
STATS_INCLUDE_SUMMARY: 8
};
NodeGit.Enums.DIRECTION = {
FETCH: 0,
PUSH: 1
};
NodeGit.Error.ERROR = {
NONE: 0,
NOMEMORY: 1,
OS: 2,
INVALID: 3,
REFERENCE: 4,
ZLIB: 5,
REPOSITORY: 6,
CONFIG: 7,
REGEX: 8,
ODB: 9,
INDEX: 10,
OBJECT: 11,
NET: 12,
TAG: 13,
TREE: 14,
INDEXER: 15,
SSL: 16,
SUBMODULE: 17,
THREAD: 18,
STASH: 19,
CHECKOUT: 20,
FETCHHEAD: 21,
MERGE: 22,
SSH: 23,
FILTER: 24,
REVERT: 25,
CALLBACK: 26,
CHERRYPICK: 27,
DESCRIBE: 28,
REBASE: 29,
FILESYSTEM: 30,
PATCH: 31,
WORKTREE: 32,
SHA1: 33
};
NodeGit.Error.CODE = {
OK: 0,
ERROR: -1,
ENOTFOUND: -3,
EEXISTS: -4,
EAMBIGUOUS: -5,
EBUFS: -6,
EUSER: -7,
EBAREREPO: -8,
EUNBORNBRANCH: -9,
EUNMERGED: -10,
ENONFASTFORWARD: -11,
EINVALIDSPEC: -12,
ECONFLICT: -13,
ELOCKED: -14,
EMODIFIED: -15,
EAUTH: -16,
ECERTIFICATE: -17,
EAPPLIED: -18,
EPEEL: -19,
EEOF: -20,
EINVALID: -21,
EUNCOMMITTED: -22,
EDIRECTORY: -23,
EMERGECONFLICT: -24,
PASSTHROUGH: -30,
ITEROVER: -31,
RETRY: -32,
EMISMATCH: -33,
EINDEXDIRTY: -34,
EAPPLYFAIL: -35
};
NodeGit.Enums.FEATURE = {
THREADS: 1,
HTTPS: 2,
SSH: 4,
NSEC: 8
};
NodeGit.Fetch.PRUNE = {
GIT_FETCH_PRUNE_UNSPECIFIED: 0,
GIT_FETCH_PRUNE: 1,
GIT_FETCH_NO_PRUNE: 2
};
NodeGit.TreeEntry.FILEMODE = {
UNREADABLE: 0,
TREE: 16384,
BLOB: 33188,
EXECUTABLE: 33261,
LINK: 40960,
COMMIT: 57344
};
NodeGit.Filter.FLAG = {
DEFAULT: 0,
ALLOW_UNSAFE: 1,
NO_SYSTEM_ATTRIBUTES: 2,
ATTRIBUTES_FROM_HEAD: 4
};
NodeGit.Filter.MODE = {
TO_WORKTREE: 0,
SMUDGE: 0,
TO_ODB: 1,
CLEAN: 1
};
NodeGit.Hashsig.OPTION = {
NORMAL: 0,
IGNORE_WHITESPACE: 1,
SMART_WHITESPACE: 2,
ALLOW_SMALL_FILES: 4
};
NodeGit.Index.ADD_OPTION = {
ADD_DEFAULT: 0,
ADD_FORCE: 1,
ADD_DISABLE_PATHSPEC_MATCH: 2,
ADD_CHECK_PATHSPEC: 4
};
NodeGit.Index.CAPABILITY = {
IGNORE_CASE: 1,
NO_FILEMODE: 2,
NO_SYMLINKS: 4,
FROM_OWNER: -1
};
NodeGit.Index.ENTRY_EXTENDED_FLAG = {
ENTRY_INTENT_TO_ADD: 8192,
ENTRY_SKIP_WORKTREE: 16384,
S: 24576,
ENTRY_UPTODATE: 4
};
NodeGit.Index.ENTRY_FLAG = {
ENTRY_EXTENDED: 16384,
ENTRY_VALID: 32768
};
NodeGit.Index.STAGE = {
ANY: -1,
NORMAL: 0,
ANCESTOR: 1,
OURS: 2,
THEIRS: 3
};
NodeGit.Libgit2.OPT = {
GET_MWINDOW_SIZE: 0,
SET_MWINDOW_SIZE: 1,
GET_MWINDOW_MAPPED_LIMIT: 2,
SET_MWINDOW_MAPPED_LIMIT: 3,
GET_SEARCH_PATH: 4,
SET_SEARCH_PATH: 5,
SET_CACHE_OBJECT_LIMIT: 6,
SET_CACHE_MAX_SIZE: 7,
ENABLE_CACHING: 8,
GET_CACHED_MEMORY: 9,
GET_TEMPLATE_PATH: 10,
SET_TEMPLATE_PATH: 11,
SET_SSL_CERT_LOCATIONS: 12,
SET_USER_AGENT: 13,
ENABLE_STRICT_OBJECT_CREATION: 14,
ENABLE_STRICT_SYMBOLIC_REF_CREATION: 15,
SET_SSL_CIPHERS: 16,
GET_USER_AGENT: 17,
ENABLE_OFS_DELTA: 18,
ENABLE_FSYNC_GITDIR: 19,
GET_WINDOWS_SHAREMODE: 20,
SET_WINDOWS_SHAREMODE: 21,
ENABLE_STRICT_HASH_VERIFICATION: 22,
SET_ALLOCATOR: 23,
ENABLE_UNSAVED_INDEX_SAFETY: 24,
GET_PACK_MAX_OBJECTS: 25,
SET_PACK_MAX_OBJECTS: 26,
DISABLE_PACK_KEEP_FILE_CHECKS: 27
};
NodeGit.Merge.ANALYSIS = {
NONE: 0,
NORMAL: 1,
UP_TO_DATE: 2,
FASTFORWARD: 4,
UNBORN: 8
};
NodeGit.Merge.FILE_FAVOR = {
NORMAL: 0,
OURS: 1,
THEIRS: 2,
UNION: 3
};
NodeGit.Merge.FILE_FLAG = {
FILE_DEFAULT: 0,
FILE_STYLE_MERGE: 1,
FILE_STYLE_DIFF3: 2,
FILE_SIMPLIFY_ALNUM: 4,
FILE_IGNORE_WHITESPACE: 8,
FILE_IGNORE_WHITESPACE_CHANGE: 16,
FILE_IGNORE_WHITESPACE_EOL: 32,
FILE_DIFF_PATIENCE: 64,
FILE_DIFF_MINIMAL: 128
};
NodeGit.Merge.FLAG = {
FIND_RENAMES: 1,
FAIL_ON_CONFLICT: 2,
SKIP_REUC: 4,
NO_RECURSIVE: 8
};
NodeGit.Merge.PREFERENCE = {
NONE: 0,
NO_FASTFORWARD: 1,
FASTFORWARD_ONLY: 2
};
NodeGit.Object.TYPE = {
ANY: -2,
INVALID: -1,
COMMIT: 1,
TREE: 2,
BLOB: 3,
TAG: 4,
OFS_DELTA: 6,
REF_DELTA: 7
};
NodeGit.Odb.STREAM = {
RDONLY: 2,
WRONLY: 4,
RW: 6
};
NodeGit.Packbuilder.STAGE = {
ADDING_OBJECTS: 0,
DELTAFICATION: 1
};
NodeGit.Path.FS = {
GENERIC: 0,
NTFS: 1,
HFS: 2
};
NodeGit.Path.GITFILE = {
GITIGNORE: 0,
GITMODULES: 1,
GITATTRIBUTES: 1
};
NodeGit.Pathspec.FLAG = {
DEFAULT: 0,
IGNORE_CASE: 1,
USE_CASE: 2,
NO_GLOB: 4,
NO_MATCH_ERROR: 8,
FIND_FAILURES: 16,
FAILURES_ONLY: 32
};
NodeGit.Proxy.PROXY = {
NONE: 0,
AUTO: 1,
SPECIFIED: 2
};
NodeGit.RebaseOperation.REBASE_OPERATION = {
PICK: 0,
REWORD: 1,
EDIT: 2,
SQUASH: 3,
FIXUP: 4,
EXEC: 5
};
NodeGit.Reference.TYPE = {
INVALID: 0,
DIRECT: 1,
SYMBOLIC: 2,
ALL: 3
};
NodeGit.Reference.FORMAT = {
NORMAL: 0,
ALLOW_ONELEVEL: 1,
REFSPEC_PATTERN: 2,
REFSPEC_SHORTHAND: 4
};
NodeGit.Remote.AUTOTAG_OPTION = {
DOWNLOAD_TAGS_UNSPECIFIED: 0,
DOWNLOAD_TAGS_AUTO: 1,
DOWNLOAD_TAGS_NONE: 2,
DOWNLOAD_TAGS_ALL: 3
};
NodeGit.Remote.COMPLETION = {
DOWNLOAD: 0,
INDEXING: 1,
ERROR: 2
};
NodeGit.Remote.CREATE_FLAGS = {
CREATE_SKIP_INSTEADOF: 1,
CREATE_SKIP_DEFAULT_FETCHSPEC: 2
};
NodeGit.Repository.INIT_FLAG = {
BARE: 1,
NO_REINIT: 2,
NO_DOTGIT_DIR: 4,
MKDIR: 8,
MKPATH: 16,
EXTERNAL_TEMPLATE: 32,
RELATIVE_GITLINK: 64
};
NodeGit.Repository.INIT_MODE = {
INIT_SHARED_UMASK: 0,
INIT_SHARED_GROUP: 1533,
INIT_SHARED_ALL: 1535
};
NodeGit.Repository.ITEM = {
GITDIR: 0,
WORKDIR: 1,
COMMONDIR: 2,
INDEX: 3,
OBJECTS: 4,
REFS: 5,
PACKED_REFS: 6,
REMOTES: 7,
CONFIG: 8,
INFO: 9,
HOOKS: 10,
LOGS: 11,
MODULES: 12,
WORKTREES: 13,
_LAST: 14
};
NodeGit.Repository.OPEN_FLAG = {
OPEN_NO_SEARCH: 1,
OPEN_CROSS_FS: 2,
OPEN_BARE: 4,
OPEN_NO_DOTGIT: 8,
OPEN_FROM_ENV: 16
};
NodeGit.Repository.STATE = {
NONE: 0,
MERGE: 1,
REVERT: 2,
REVERT_SEQUENCE: 3,
CHERRYPICK: 4,
CHERRYPICK_SEQUENCE: 5,
BISECT: 6,
REBASE: 7,
REBASE_INTERACTIVE: 8,
REBASE_MERGE: 9,
APPLY_MAILBOX: 10,
APPLY_MAILBOX_OR_REBASE: 11
};
NodeGit.Reset.TYPE = {
SOFT: 1,
MIXED: 2,
HARD: 3
};
NodeGit.Revparse.MODE = {
SINGLE: 1,
RANGE: 2,
MERGE_BASE: 4
};
NodeGit.Enums.SMART_SERVICE = {
SERVICE_UPLOADPACK_LS: 1,
SERVICE_UPLOADPACK: 2,
SERVICE_RECEIVEPACK_LS: 3,
SERVICE_RECEIVEPACK: 4
};
NodeGit.Revwalk.SORT = {
NONE: 0,
TOPOLOGICAL: 1,
TIME: 2,
REVERSE: 4
};
NodeGit.Stash.APPLY_FLAGS = {
APPLY_DEFAULT: 0,
APPLY_REINSTATE_INDEX: 1
};
NodeGit.Stash.APPLY_PROGRESS = {
NONE: 0,
LOADING_STASH: 1,
ANALYZE_INDEX: 2,
ANALYZE_MODIFIED: 3,
ANALYZE_UNTRACKED: 4,
CHECKOUT_UNTRACKED: 5,
CHECKOUT_MODIFIED: 6,
DONE: 7
};
NodeGit.Stash.FLAGS = {
DEFAULT: 0,
KEEP_INDEX: 1,
INCLUDE_UNTRACKED: 2,
INCLUDE_IGNORED: 4
};
NodeGit.Status.STATUS = {
CURRENT: 0,
INDEX_NEW: 1,
INDEX_MODIFIED: 2,
INDEX_DELETED: 4,
INDEX_RENAMED: 8,
INDEX_TYPECHANGE: 16,
WT_NEW: 128,
WT_MODIFIED: 256,
WT_DELETED: 512,
WT_TYPECHANGE: 1024,
WT_RENAMED: 2048,
WT_UNREADABLE: 4096,
IGNORED: 16384,
CONFLICTED: 32768
};
NodeGit.Status.OPT = {
INCLUDE_UNTRACKED: 1,
INCLUDE_IGNORED: 2,
INCLUDE_UNMODIFIED: 4,
EXCLUDE_SUBMODULES: 8,
RECURSE_UNTRACKED_DIRS: 16,
DISABLE_PATHSPEC_MATCH: 32,
RECURSE_IGNORED_DIRS: 64,
RENAMES_HEAD_TO_INDEX: 128,
RENAMES_INDEX_TO_WORKDIR: 256,
SORT_CASE_SENSITIVELY: 512,
SORT_CASE_INSENSITIVELY: 1024,
RENAMES_FROM_REWRITES: 2048,
NO_REFRESH: 4096,
UPDATE_INDEX: 8192,
INCLUDE_UNREADABLE: 16384,
INCLUDE_UNREADABLE_AS_UNTRACKED: 32768
};
NodeGit.Status.SHOW = {
INDEX_AND_WORKDIR: 0,
INDEX_ONLY: 1,
WORKDIR_ONLY: 2
};
NodeGit.Submodule.IGNORE = {
UNSPECIFIED: -1,
NONE: 1,
UNTRACKED: 2,
DIRTY: 3,
ALL: 4
};
NodeGit.Submodule.RECURSE = {
NO: 0,
YES: 1,
ONDEMAND: 2
};
NodeGit.Submodule.STATUS = {
IN_HEAD: 1,
IN_INDEX: 2,
IN_CONFIG: 4,
IN_WD: 8,
INDEX_ADDED: 16,
INDEX_DELETED: 32,
INDEX_MODIFIED: 64,
WD_UNINITIALIZED: 128,
WD_ADDED: 256,
WD_DELETED: 512,
WD_MODIFIED: 1024,
WD_INDEX_MODIFIED: 2048,
WD_WD_MODIFIED: 4096,
WD_UNTRACKED: 8192
};
NodeGit.Submodule.UPDATE = {
CHECKOUT: 1,
REBASE: 2,
MERGE: 3,
NONE: 4,
DEFAULT: 0
};
NodeGit.Trace.LEVEL = {
NONE: 0,
FATAL: 1,
ERROR: 2,
WARN: 3,
INFO: 4,
DEBUG: 5,
TRACE: 6
};
NodeGit.Tree.UPDATE = {
UPSERT: 0,
REMOVE: 1
};
NodeGit.Tree.WALK_MODE = {
WALK_PRE: 0,
WALK_POST: 1
};
NodeGit.Worktree.PRUNE = {
GIT_WORKTREE_PRUNE_VALID: 1,
GIT_WORKTREE_PRUNE_LOCKED: 2,
GIT_WORKTREE_PRUNE_WORKING_TREE: 4
};
+17
View File
@@ -0,0 +1,17 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
// Deprecated -----------------------------------------------------------------
// In 0.28.0 git_error was majorly refactored to have better naming in libgit2
// We will continue to support the old enum entries but with a deprecation
// warning as they will go away soon.
Object.keys(NodeGit.Error.CODE).forEach(function (key) {
Object.defineProperty(NodeGit.Error.CODE, "GITERR_" + key, {
get: util.deprecate(function () {
return NodeGit.Error.CODE[key];
}, "Use NodeGit.Error.CODE." + key + " instead of " + ("NodeGit.Error.CODE.GETERR_" + key + "."))
});
});
+25
View File
@@ -0,0 +1,25 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var FilterRegistry = NodeGit.FilterRegistry;
var _register = FilterRegistry.register;
// register should add filter by name to dict and return
// Override FilterRegistry.register to normalize Filter
FilterRegistry.register = function (name, filter, priority) {
// setting default value of attributes
if (filter.attributes === undefined) {
filter.attributes = "";
}
filter = normalizeOptions(filter, NodeGit.Filter);
if (!filter.check || !filter.apply) {
return Promise.reject(new Error("ERROR: please provide check and apply callbacks for filter"));
}
return _register(name, filter, priority);
};
+96
View File
@@ -0,0 +1,96 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var Index = NodeGit.Index;
var _addAll = Index.prototype.addAll;
var _removeAll = Index.prototype.removeAll;
var _updateAll = Index.prototype.updateAll;
Index.prototype.addAll = function (pathspec, flags, matchedCallback) {
return _addAll.call(this, pathspec || "*", flags, matchedCallback, null);
};
/**
* Return an array of the entries in this index.
* @return {Array<IndexEntry>} an array of IndexEntrys
*/
Index.prototype.entries = function () {
var size = this.entryCount();
var result = [];
for (var i = 0; i < size; i++) {
result.push(this.getByIndex(i));
}
return result;
};
Index.prototype.removeAll = function (pathspec, matchedCallback) {
return _removeAll.call(this, pathspec || "*", matchedCallback, null);
};
Index.prototype.updateAll = function (pathspec, matchedCallback) {
return _updateAll.call(this, pathspec || "*", matchedCallback, null);
};
// Deprecated -----------------------------------------------------------------
NodeGit.Index.CAP = {};
Object.keys(NodeGit.Index.CAPABILITY).forEach(function (key) {
Object.defineProperty(NodeGit.Index.CAP, key, {
get: util.deprecate(function () {
return NodeGit.Index.CAPABILITY[key];
}, "Use NodeGit.Index.CAPABILITY." + key + " instead of " + ("NodeGit.Index.CAP." + key + "."))
});
});
NodeGit.Enums.INDXENTRY_FLAG = {};
Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_EXTENDED", {
get: util.deprecate(function () {
return NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED;
}, "Use NodeGit.Index.ENTRY_FLAG.ENTRY_EXTENDED instead of " + "NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_EXTENDED.")
});
Object.defineProperty(NodeGit.Enums.INDXENTRY_FLAG, "IDXENTRY_VALID", {
get: util.deprecate(function () {
return NodeGit.Index.ENTRY_FLAG.ENTRY_VALID;
}, "Use NodeGit.Index.ENTRY_FLAG.ENTRY_VALID instead of " + "NodeGit.Enums.INDXENTRY_FLAG.IDXENTRY_VALID.")
});
NodeGit.Enums.IDXENTRY_EXTENDED_FLAG = {};
var EXTENDED_FLAGS_MAP = {
IDXENTRY_INTENT_TO_ADD: "ENTRY_INTENT_TO_ADD",
IDXENTRY_SKIP_WORKTREE: "ENTRY_SKIP_WORKTREE",
S: "S",
IDXENTRY_UPTODATE: "ENTRY_UPTODATE"
};
Object.keys(EXTENDED_FLAGS_MAP).forEach(function (key) {
var newKey = EXTENDED_FLAGS_MAP[key];
Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, {
get: util.deprecate(function () {
return NodeGit.Index.ENTRY_EXTENDED_FLAG[newKey];
}, "Use NodeGit.Index.ENTRY_EXTENDED_FLAG." + newKey + " instead of " + ("NodeGit.Enums.IDXENTRY_EXTENDED_FLAG." + key + "."))
});
});
var DEPRECATED_EXTENDED_FLAGS = {
IDXENTRY_EXTENDED2: 32768,
IDXENTRY_UPDATE: 1,
IDXENTRY_REMOVE: 2,
IDXENTRY_ADDED: 8,
IDXENTRY_HASHED: 16,
IDXENTRY_UNHASHED: 32,
IDXENTRY_WT_REMOVE: 64,
IDXENTRY_CONFLICTED: 128,
IDXENTRY_UNPACKED: 256,
IDXENTRY_NEW_SKIP_WORKTREE: 512
};
Object.keys(DEPRECATED_EXTENDED_FLAGS).forEach(function (key) {
Object.defineProperty(NodeGit.Enums.IDXENTRY_EXTENDED_FLAG, key, {
get: util.deprecate(function () {
return DEPRECATED_EXTENDED_FLAGS[key];
}, "LibGit2 has removed this flag for public usage.")
});
});
+8
View File
@@ -0,0 +1,8 @@
"use strict";
var NodeGit = require("../");
var Libgit2 = NodeGit.Libgit2;
Libgit2.OPT.SET_WINDOWS_LONGPATHS = 28;
Libgit2.OPT.GET_WINDOWS_LONGPATHS = 29;
+45
View File
@@ -0,0 +1,45 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Merge = NodeGit.Merge;
var _commits = Merge.commits;
var _merge = Merge.merge;
/**
* Merge 2 commits together and create an new index that can
* be used to create a merge commit.
*
* @param {Repository} repo Repository that contains the given commits
* @param {Commit} ourCommit The commit that reflects the destination tree
* @param {Commit} theirCommit The commit to merge into ourCommit
* @param {MergeOptions} [options] The merge tree options (null for default)
*/
Merge.commits = function (repo, ourCommit, theirCommit, options) {
options = normalizeOptions(options, NodeGit.MergeOptions);
return Promise.all([repo.getCommit(ourCommit), repo.getCommit(theirCommit)]).then(function (commits) {
return _commits.call(this, repo, commits[0], commits[1], options);
});
};
/**
* Merge a commit into HEAD and writes the results to the working directory.
*
* @param {Repository} repo Repository that contains the given commits
* @param {AnnotatedCommit} theirHead The annotated commit to merge into HEAD
* @param {MergeOptions} [mergeOpts] The merge tree options (null for default)
* @param {CheckoutOptions} [checkoutOpts] The checkout options
* (null for default)
*/
Merge.merge = function (repo, theirHead, mergeOpts, checkoutOpts) {
mergeOpts = normalizeOptions(mergeOpts || {}, NodeGit.MergeOptions);
checkoutOpts = normalizeOptions(checkoutOpts || {}, NodeGit.CheckoutOptions);
// Even though git_merge takes an array of annotated_commits, it expects
// exactly one to have been passed in or it will throw an error... ¯\_(ツ)_/¯
var theirHeads = [theirHead];
return _merge.call(this, repo, theirHeads, theirHeads.length, mergeOpts, checkoutOpts);
};
+1312
View File
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var NodeGit = require("../");
var Note = NodeGit.Note;
var _foreach = Note.foreach;
// Override Note.foreach to eliminate the need to pass null payload
Note.foreach = function (repo, notesRef, callback) {
function wrapperCallback(blobId, objectId) {
// We need to copy the OID since libgit2 types are getting cleaned up
// incorrectly right now in callbacks
return callback(blobId.copy(), objectId.copy());
}
return _foreach(repo, notesRef, wrapperCallback, null);
};
+46
View File
@@ -0,0 +1,46 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var Obj = NodeGit.Object;
/**
* Is this object a blob?
* @return {Boolean}
*/
Obj.prototype.isBlob = function () {
return this.type() == Obj.TYPE.BLOB;
};
/**
* Is this object a commit?
* @return {Boolean}
*/
Obj.prototype.isCommit = function () {
return this.type() == Obj.TYPE.COMMIT;
};
/**
* Is this object a tag?
* @return {Boolean}
*/
Obj.prototype.isTag = function () {
return this.type() == Obj.TYPE.TAG;
};
/**
* Is this object a tree?
* @return {Boolean}
*/
Obj.prototype.isTree = function () {
return this.type() == Obj.TYPE.TREE;
};
// Deprecated -----------------------------------------------------------------
Object.defineProperty(Obj.TYPE, "BAD", {
get: util.deprecate(function () {
return Obj.TYPE.INVALID;
}, "Use NodeGit.Object.TYPE.INVALID instead of NodeGit.Object.TYPE.BAD.")
});
+11
View File
@@ -0,0 +1,11 @@
"use strict";
var NodeGit = require("../");
var OdbObject = NodeGit.OdbObject;
OdbObject.prototype.toString = function (size) {
size = size || this.size();
return this.data().toBuffer(size).toString();
};
+25
View File
@@ -0,0 +1,25 @@
"use strict";
var NodeGit = require("../");
var Oid = NodeGit.Oid;
// Backwards compatibility.
Object.defineProperties(Oid.prototype, {
"allocfmt": {
value: Oid.prototype.tostrS,
enumerable: false
},
"toString": {
value: Oid.prototype.tostrS,
enumerable: false
}
});
Oid.prototype.copy = function () {
return this.cpy(); // seriously???
};
Oid.prototype.inspect = function () {
return "[Oid " + this.allocfmt() + "]";
};
+130
View File
@@ -0,0 +1,130 @@
"use strict";
var NodeGit = require("../");
var Rebase = NodeGit.Rebase;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = NodeGit.Utils.shallowClone;
var _init = Rebase.init;
var _open = Rebase.open;
var _abort = Rebase.prototype.abort;
var _commit = Rebase.prototype.commit;
function defaultRebaseOptions(options, checkoutStrategy) {
var checkoutOptions = void 0;
var mergeOptions = void 0;
if (options) {
options = shallowClone(options);
checkoutOptions = options.checkoutOptions;
mergeOptions = options.mergeOptions;
delete options.checkoutOptions;
delete options.mergeOptions;
if (options.signingCb) {
var signingCb = options.signingCb;
options.signingCb = function (signatureBuf, signatureFieldBuf, commitContent) {
try {
var signingCbResult = signingCb(commitContent);
return Promise.resolve(signingCbResult).then(function (_ref) {
var code = _ref.code,
field = _ref.field,
signedData = _ref.signedData;
if (code === NodeGit.Error.CODE.OK) {
signatureBuf.setString(signedData);
if (field) {
signatureFieldBuf.setString(field);
}
}
return code;
}).catch(function (error) {
if (error && error.code) {
return error.code;
}
return NodeGit.Error.CODE.ERROR;
});
} catch (error) {
if (error && error.code) {
return error.code;
}
return NodeGit.Error.CODE.ERROR;
}
};
}
options = normalizeOptions(options, NodeGit.RebaseOptions);
} else {
options = normalizeOptions({}, NodeGit.RebaseOptions);
if (checkoutStrategy) {
checkoutOptions = {
checkoutStrategy: checkoutStrategy
};
}
}
if (checkoutOptions) {
options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions);
}
if (mergeOptions) {
options.mergeOptions = normalizeOptions(mergeOptions, NodeGit.MergeOptions);
}
return options;
}
// Save options on the rebase object. If we don't do this,
// the options may be cleaned up and cause a segfault
// when Rebase.prototype.commit is called.
var lockOptionsOnRebase = function lockOptionsOnRebase(options) {
return function (rebase) {
Object.defineProperty(rebase, "options", {
value: options,
writable: false
});
return rebase;
};
};
/**
* Initializes a rebase
* @async
* @param {Repository} repo The repository to perform the rebase
* @param {AnnotatedCommit} branch The terminal commit to rebase, or NULL to
* rebase the current branch
* @param {AnnotatedCommit} upstream The commit to begin rebasing from, or NULL
* to rebase all reachable commits
* @param {AnnotatedCommit} onto The branch to rebase onto, or NULL to rebase
* onto the given upstream
* @param {RebaseOptions} options Options to specify how rebase is performed,
* or NULL
* @return {Remote}
*/
Rebase.init = function (repository, branch, upstream, onto, options) {
options = defaultRebaseOptions(options, NodeGit.Checkout.STRATEGY.FORCE);
return _init(repository, branch, upstream, onto, options).then(lockOptionsOnRebase(options));
};
/**
* Opens an existing rebase that was previously started by either an invocation
* of Rebase.open or by another client.
* @async
* @param {Repository} repo The repository that has a rebase in-progress
* @param {RebaseOptions} options Options to specify how rebase is performed
* @return {Remote}
*/
Rebase.open = function (repository, options) {
options = defaultRebaseOptions(options, NodeGit.Checkout.STRATEGY.SAFE);
return _open(repository, options).then(lockOptionsOnRebase(options));
};
Rebase.prototype.commit = function (author, committer, encoding, message) {
return _commit.call(this, author, committer, encoding, message);
};
Rebase.prototype.abort = function () {
return _abort.call(this);
};
+196
View File
@@ -0,0 +1,196 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var Reference = NodeGit.Reference;
var Branch = NodeGit.Branch;
/**
* Retrieves the reference by it's short name
* @async
* @param {Repository} repo The repo that the reference lives in
* @param {String|Reference} id The reference to lookup
* @param {Function} callback
* @return {Reference}
*/
Reference.dwim = LookupWrapper(Reference, Reference.dwim);
/**
* Retrieves the reference pointed to by the oid
* @async
* @param {Repository} repo The repo that the reference lives in
* @param {String|Reference} id The reference to lookup
* @param {Function} callback
* @return {Reference}
*/
Reference.lookup = LookupWrapper(Reference);
/**
* Returns true if this reference is not symbolic
* @return {Boolean}
*/
Reference.prototype.isConcrete = function () {
return this.type() == Reference.TYPE.DIRECT;
};
/**
* Returns if the ref is pointed at by HEAD
* @return {Boolean}
*/
Reference.prototype.isHead = function () {
return Branch.isHead(this);
};
/**
* Returns true if this reference is symbolic
* @return {Boolean}
*/
Reference.prototype.isSymbolic = function () {
return this.type() == Reference.TYPE.SYMBOLIC;
};
/**
* Returns true if this reference is valid
* @return {Boolean}
*/
Reference.prototype.isValid = function () {
return this.type() != Reference.TYPE.INVALID;
};
/**
* Returns the name of the reference.
* @return {String}
*/
Reference.prototype.toString = function () {
return this.name();
};
var getTerminal = function getTerminal(repo, refName) {
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10;
var prevRef = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
if (depth <= 0) {
return Promise.resolve({
error: NodeGit.Error.CODE.ENOTFOUND,
out: prevRef
});
}
return NodeGit.Reference.lookup(repo, refName).then(function (ref) {
if (ref.type() === NodeGit.Reference.TYPE.DIRECT) {
return {
error: NodeGit.Error.CODE.OK,
out: ref
};
} else {
return getTerminal(repo, ref.symbolicTarget(), depth - 1, ref).then(function (_ref) {
var error = _ref.error,
out = _ref.out;
if (error === NodeGit.Error.CODE.ENOTFOUND && !out) {
return { error: error, out: ref };
} else {
return { error: error, out: out };
}
});
}
}).catch(function (error) {
return {
error: error.errno,
out: null
};
});
};
var getSignatureForReflog = function getSignatureForReflog(repo) {
var _repo$ident = repo.ident(),
email = _repo$ident.email,
name = _repo$ident.name;
if (email && name) {
return Promise.resolve(NodeGit.Signature.now(name, email));
}
return NodeGit.Signature.default(repo).catch(function () {
return NodeGit.Signature.now("unknown", "unknown");
});
};
/**
* Given a reference name, follows symbolic links and updates the direct
* reference to point to a given OID. Updates the reflog with a given message.
*
* @async
* @param {Repository} repo The repo where the reference and objects live
* @param {String} refName The reference name to update
* @param {Oid} oid The target OID that the reference will point to
* @param {String} logMessage The reflog message to be writted
* @param {Signature} signature Optional signature to use for the reflog entry
*/
Reference.updateTerminal = function (repo, refName, oid, logMessage, signature) {
var signatureToUse = void 0;
var promiseChain = Promise.resolve();
if (!signature) {
promiseChain = promiseChain.then(function () {
return getSignatureForReflog(repo);
}).then(function (sig) {
signatureToUse = sig;
return Promise.resolve();
});
} else {
signatureToUse = signature;
}
return promiseChain.then(function () {
return getTerminal(repo, refName);
}).then(function (_ref2) {
var error = _ref2.error,
out = _ref2.out;
if (error === NodeGit.Error.CODE.ENOTFOUND && out) {
return NodeGit.Reference.create(repo, out.symbolicTarget(), oid, 0, logMessage);
} else if (error === NodeGit.Error.CODE.ENOTFOUND) {
return NodeGit.Reference.create(repo, refName, oid, 0, logMessage);
} else {
return NodeGit.Reference.createMatching(repo, out.name(), oid, 1, out.target(), logMessage);
}
}).then(function () {
return NodeGit.Reflog.read(repo, refName);
}).then(function (reflog) {
// Janky, but works. Ideally, we would want to generate the correct reflog
// entry in the first place, rather than drop the most recent entry and
// write the correct one.
// NOTE: There is a theoretical race condition that could happen here.
// We may want to consider some kind of transactional logic to make sure
// that the reflog on disk isn't modified before we can write back.
reflog.drop(0, 1);
reflog.append(oid, signatureToUse, logMessage);
return reflog.write();
});
};
// Deprecated -----------------------------------------------------------------
Object.defineProperty(NodeGit.Reference.TYPE, "OID", {
get: util.deprecate(function () {
return NodeGit.Reference.TYPE.DIRECT;
}, "Use NodeGit.Reference.TYPE.DIRECT instead of NodeGit.Reference.TYPE.OID.")
});
Object.defineProperty(NodeGit.Reference.TYPE, "LISTALL", {
get: util.deprecate(function () {
return NodeGit.Reference.TYPE.ALL;
}, "Use NodeGit.Reference.TYPE.ALL instead of NodeGit.Reference.TYPE.LISTALL.")
});
NodeGit.Reference.NORMALIZE = {};
Object.keys(NodeGit.Reference.FORMAT).forEach(function (key) {
Object.defineProperty(NodeGit.Reference.NORMALIZE, "REF_FORMAT_" + key, {
get: util.deprecate(function () {
return NodeGit.Reference.FORMAT[key];
}, "Use NodeGit.Reference.FORMAT." + key + " instead of " + ("NodeGit.Reference.NORMALIZE.REF_FORMAT_" + key + "."))
});
});
+249
View File
@@ -0,0 +1,249 @@
"use strict";
var util = require("util");
var NodeGit = require("../");
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var lookupWrapper = NodeGit.Utils.lookupWrapper;
var shallowClone = NodeGit.Utils.shallowClone;
var Remote = NodeGit.Remote;
var _connect = Remote.prototype.connect;
var _createWithOpts = Remote.createWithOpts;
var _disconnect = Remote.prototype.disconnect;
var _download = Remote.prototype.download;
var _fetch = Remote.prototype.fetch;
var _push = Remote.prototype.push;
var _updateTips = Remote.prototype.updateTips;
var _upload = Remote.prototype.upload;
/**
* Retrieves the remote by name
* @async
* @param {Repository} repo The repo that the remote lives in
* @param {String|Remote} name The remote to lookup
* @param {Function} callback
* @return {Remote}
*/
Remote.lookup = lookupWrapper(Remote);
/**
* Connects to a remote
*
* @async
* @param {Enums.DIRECTION} direction The direction for the connection
* @param {RemoteCallbacks} callbacks The callback functions for the connection
* @param {ProxyOptions} proxyOpts Proxy settings
* @param {Array<string>} customHeaders extra HTTP headers to use
* @param {Function} callback
* @return {Number} error code
*/
Remote.prototype.connect = function (direction, callbacks, proxyOpts, customHeaders) {
var _this = this;
callbacks = normalizeOptions(callbacks || {}, NodeGit.RemoteCallbacks);
proxyOpts = normalizeOptions(proxyOpts || {}, NodeGit.ProxyOptions);
customHeaders = customHeaders || [];
return _connect.call(this, direction, callbacks, proxyOpts, customHeaders).then(function () {
// Save options on the remote object. If we don't do this,
// the options may be cleaned up and cause a segfault
// when Remote.prototype.connect is called.
Object.defineProperties(_this, {
callbacks: {
configurable: true,
value: callbacks,
writable: false
},
proxyOpts: {
configurable: true,
value: proxyOpts,
writable: false
},
customHeaders: {
configurable: true,
value: customHeaders,
writable: false
}
});
});
};
Remote.createWithOpts = function (url, options) {
return _createWithOpts(url, normalizeOptions(options, NodeGit.RemoteCreateOptions));
};
Remote.prototype.disconnect = function () {
var _this2 = this;
return _disconnect.call(this).then(function () {
// Release the options
Object.defineProperties(_this2, {
callbacks: {
configurable: true,
value: undefined,
writable: false
},
proxyOpts: {
configurable: true,
value: undefined,
writable: false
},
customHeaders: {
configurable: true,
value: undefined,
writable: false
}
});
});
};
/**
* Connects to a remote
*
* @async
* @param {Array} refSpecs The ref specs that should be pushed
* @param {FetchOptions} opts The fetch options for download, contains callbacks
* @param {Function} callback
* @return {Number} error code
*/
Remote.prototype.download = function (refspecs, opts) {
return _download.call(this, refspecs, normalizeFetchOptions(opts));
};
/**
* Connects to a remote
*
* @async
* @param {Array} refSpecs The ref specs that should be pushed
* @param {FetchOptions} opts The fetch options for download, contains callbacks
* @param {String} message The message to use for the update reflog messages
* @param {Function} callback
* @return {Number} error code
*/
Remote.prototype.fetch = function (refspecs, opts, reflog_message) {
return _fetch.call(this, refspecs, normalizeFetchOptions(opts), reflog_message);
};
/**
* Pushes to a remote
*
* @async
* @param {Array} refSpecs The ref specs that should be pushed
* @param {PushOptions} options Options for the checkout
* @param {Function} callback
* @return {Number} error code
*/
Remote.prototype.push = function (refSpecs, opts) {
var callbacks;
var proxyOpts;
if (opts) {
opts = shallowClone(opts);
callbacks = opts.callbacks;
proxyOpts = opts.proxyOpts;
delete opts.callbacks;
delete opts.proxyOpts;
} else {
opts = {};
}
opts = normalizeOptions(opts, NodeGit.PushOptions);
if (callbacks) {
opts.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
}
if (proxyOpts) {
opts.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions);
}
return _push.call(this, refSpecs, opts);
};
/**
* Lists advertised references from a remote. You must connect to the remote
* before using referenceList.
*
* @async
* @return {Promise<Array<RemoteHead>>} a list of the remote heads the remote
* had available at the last established
* connection.
*
*/
Remote.prototype.referenceList = Remote.prototype.referenceList;
/**
* Update the tips to the new state
* @param {RemoteCallbacks} callbacks The callback functions for the connection
* @param {boolean} updateFetchhead whether to write to FETCH_HEAD. Pass true
* to behave like git.
* @param {boolean} downloadTags what the behaviour for downloading tags is
* for this fetch. This is ignored for push.
* This must be the same value passed to
* Remote.prototype.download
* @param {string} reflogMessage The message to insert into the reflogs. If
* null and fetching, the default is "fetch ",
* where is the name of the remote (or its url,
* for in-memory remotes). This parameter is
* ignored when pushing.
*/
Remote.prototype.updateTips = function (callbacks, updateFetchhead, downloadTags, reflogMessage) {
if (callbacks) {
callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
}
return _updateTips.call(this, callbacks, updateFetchhead, downloadTags, reflogMessage);
};
/**
* Pushes to a remote
*
* @async
* @param {Array} refSpecs The ref specs that should be pushed
* @param {PushOptions} options Options for the checkout
* @param {Function} callback
* @return {Number} error code
*/
Remote.prototype.upload = function (refSpecs, opts) {
var callbacks;
var proxyOpts;
if (opts) {
opts = shallowClone(opts);
callbacks = opts.callbacks;
proxyOpts = opts.proxyOpts;
delete opts.callbacks;
delete opts.proxyOpts;
} else {
opts = {};
}
opts = normalizeOptions(opts, NodeGit.PushOptions);
if (callbacks) {
opts.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
}
if (proxyOpts) {
opts.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions);
}
return _upload.call(this, refSpecs, opts);
};
NodeGit.Remote.COMPLETION_TYPE = {};
var DEPRECATED_STATES = {
COMPLETION_DOWNLOAD: "DOWNLOAD",
COMPLETION_INDEXING: "INDEXING",
COMPLETION_ERROR: "ERROR"
};
Object.keys(DEPRECATED_STATES).forEach(function (key) {
var newKey = DEPRECATED_STATES[key];
Object.defineProperty(NodeGit.Remote.COMPLETION_TYPE, key, {
get: util.deprecate(function () {
return NodeGit.Remote.COMPLETION[newKey];
}, "Use NodeGit.Remote.COMPLETION." + newKey + " instead of " + ("NodeGit.Remote.COMPLETION_TYPE." + key + "."))
});
});
+1629
View File
File diff suppressed because it is too large Load Diff
+78
View File
@@ -0,0 +1,78 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Reset = NodeGit.Reset;
var _default = Reset.default;
var _reset = Reset.reset;
var _fromAnnotated = Reset.fromAnnotated;
/**
* Look up a refs's commit.
*
* @async
* @param {Repository} repo Repository where to perform the reset operation.
* @param {Commit|Tag} target The committish which content will be used to reset
* the content of the index.
* @param {Strarray} pathspecs List of pathspecs to operate on.
*
* @return {Number} 0 on success or an error code
*/
Reset.default = function (repo, target, pathspecs) {
return _default.call(this, repo, target, pathspecs);
};
/**
* Reset a repository's current HEAD to the specified target.
*
* @async
* @param {Repository} repo Repository where to perform the reset operation.
*
* @param {Commit|Tag} target Committish to which the Head should be moved to.
* This object must belong to the given `repo` and can
* either be a git_commit or a git_tag. When a git_tag is
* being passed, it should be dereferencable to a
* git_commit which oid will be used as the target of the
* branch.
* @param {Number} resetType Kind of reset operation to perform.
*
* @param {CheckoutOptions} opts Checkout options to be used for a HARD reset.
* The checkout_strategy field will be overridden
* (based on reset_type). This parameter can be
* used to propagate notify and progress
* callbacks.
*
* @return {Number} 0 on success or an error code
*/
Reset.reset = function (repo, target, resetType, opts) {
opts = normalizeOptions(opts, NodeGit.CheckoutOptions);
if (repo !== target.repo) {
// this is the same that is performed on libgit2's side
// https://github.com/nodegit/libgit2/blob/8d89e409616831b7b30a5ca7b89354957137b65e/src/reset.c#L120-L124
throw new Error("Repository and target commit's repository does not match");
}
return _reset.call(this, repo, target, resetType, opts);
};
/**
* Sets the current head to the specified commit oid and optionally
* resets the index and working tree to match.
*
* This behaves like reset but takes an annotated commit, which lets
* you specify which extended sha syntax string was specified by a
* user, allowing for more exact reflog messages.
*
* See the documentation for reset.
*
* @async
* @param {Repository} repo
* @param {AnnotatedCommit} target
* @param {Number} resetType
* @param {CheckoutOptions} opts
*/
Reset.fromAnnotated = function (repo, target, resetType, opts) {
opts = normalizeOptions(opts, NodeGit.CheckoutOptions);
return _fromAnnotated.call(this, repo, target, resetType, opts);
};
+63
View File
@@ -0,0 +1,63 @@
"use strict";
var NodeGit = require("../");
var shallowClone = NodeGit.Utils.shallowClone;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Revert = NodeGit.Revert;
var _commit = Revert.commit;
var _revert = Revert.revert;
/**
* Reverts the given commit against the given "our" commit, producing an index
* that reflects the result of the revert.
*
* @async
* @param {Repository} repo the repository that contains the given commits.
* @param {Commit} revert_commit the commit to revert
* @param {Commit} our_commit the commit to revert against (e.g. HEAD)
* @param {Number} mainline the parent of the revert commit, if it is a merge
* @param {MergeOptions} merge_options the merge options (or null for defaults)
*
* @return {Index} the index result
*/
Revert.commit = function (repo, revert_commit, our_commit, mainline, merge_options) {
merge_options = normalizeOptions(merge_options, NodeGit.MergeOptions);
return _commit.call(this, repo, revert_commit, our_commit, mainline, merge_options);
};
/**
* Reverts the given commit, producing changes in the index and
* working directory.
*
* @async
* @param {Repository} repo the repository to perform the revert in
* @param {Commit} commit the commit to revert
* @param {RevertOptions} revert_options the revert options
* (or null for defaults)
*/
Revert.revert = function (repo, commit, revertOpts) {
var mergeOpts;
var checkoutOpts;
if (revertOpts) {
revertOpts = shallowClone(revertOpts);
mergeOpts = revertOpts.mergeOpts;
checkoutOpts = revertOpts.checkoutOpts;
delete revertOpts.mergeOpts;
delete revertOpts.checkoutOpts;
}
revertOpts = normalizeOptions(revertOpts, NodeGit.RevertOptions);
if (mergeOpts) {
revertOpts.mergeOpts = normalizeOptions(mergeOpts, NodeGit.MergeOptions);
}
if (checkoutOpts) {
revertOpts.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions);
}
return _revert.call(this, repo, commit, revertOpts);
};
+146
View File
@@ -0,0 +1,146 @@
"use strict";
var NodeGit = require("../");
var Revwalk = NodeGit.Revwalk;
Object.defineProperty(Revwalk.prototype, "repo", {
get: function get() {
return this.repository();
},
configurable: true
});
var _sorting = Revwalk.prototype.sorting;
/**
* @typedef historyEntry
* @type {Object}
* @property {Commit} commit the commit for this entry
* @property {Number} status the status of the file in the commit
* @property {String} newName the new name that is provided when status is
* renamed
* @property {String} oldName the old name that is provided when status is
* renamed
*/
var fileHistoryWalk = Revwalk.prototype.fileHistoryWalk;
/**
* @param {String} filePath
* @param {Number} max_count
* @async
* @return {Array<historyEntry>}
*/
Revwalk.prototype.fileHistoryWalk = fileHistoryWalk;
/**
* Get a number of commits.
*
* @async
* @param {Number} count (default: 10)
* @return {Array<Commit>}
*/
Revwalk.prototype.getCommits = function (count) {
count = count || 10;
var promises = [];
var walker = this;
function walkCommitsCount(count) {
if (count === 0) {
return;
}
return walker.next().then(function (oid) {
promises.push(walker.repo.getCommit(oid));
return walkCommitsCount(count - 1);
}).catch(function (error) {
if (error.errno !== NodeGit.Error.CODE.ITEROVER) {
throw error;
}
});
}
return walkCommitsCount(count).then(function () {
return Promise.all(promises);
});
};
/**
* Walk the history grabbing commits until the checkFn called with the
* current commit returns false.
*
* @async
* @param {Function} checkFn function returns false to stop walking
* @return {Array}
*/
Revwalk.prototype.getCommitsUntil = function (checkFn) {
var commits = [];
var walker = this;
function walkCommitsCb() {
return walker.next().then(function (oid) {
return walker.repo.getCommit(oid).then(function (commit) {
commits.push(commit);
if (checkFn(commit)) {
return walkCommitsCb();
}
});
}).catch(function (error) {
if (error.errno !== NodeGit.Error.CODE.ITEROVER) {
throw error;
}
});
}
return walkCommitsCb().then(function () {
return commits;
});
};
/**
* Set the sort order for the revwalk. This function takes variable arguments
* like `revwalk.sorting(NodeGit.RevWalk.Topological, NodeGit.RevWalk.Reverse).`
*
* @param {Number} sort
*/
Revwalk.prototype.sorting = function () {
var sort = 0;
for (var i = 0; i < arguments.length; i++) {
sort |= arguments[i];
}
_sorting.call(this, sort);
};
/**
* Walk the history from the given oid. The callback is invoked for each commit;
* When the walk is over, the callback is invoked with `(null, null)`.
*
* @param {Oid} oid
* @param {Function} callback
*/
Revwalk.prototype.walk = function (oid, callback) {
var revwalk = this;
this.push(oid);
function walk() {
revwalk.next().then(function (oid) {
if (!oid) {
if (typeof callback === "function") {
return callback();
}
return;
}
revwalk.repo.getCommit(oid).then(function (commit) {
if (typeof callback === "function") {
callback(null, commit);
}
walk();
});
}, callback);
}
walk();
};
+40
View File
@@ -0,0 +1,40 @@
"use strict";
var NodeGit = require("../");
var Signature = NodeGit.Signature;
var toPaddedDoubleDigitString = function toPaddedDoubleDigitString(number) {
if (number < 10) {
return "0" + number;
}
return "" + number;
};
/**
* Standard string representation of an author.
* @param {Boolean} withTime Whether or not to include timestamp
* @return {String} Representation of the author.
*/
Signature.prototype.toString = function (withTime) {
var name = this.name().toString();
var email = this.email().toString();
var stringifiedSignature = name + " <" + email + ">";
if (!withTime) {
return stringifiedSignature;
}
var when = this.when();
var offset = when.offset();
var offsetMagnitude = Math.abs(offset);
var time = when.time();
var sign = offset < 0 || when.sign() === "-" ? "-" : "+";
var hours = toPaddedDoubleDigitString(Math.floor(offsetMagnitude / 60));
var minutes = toPaddedDoubleDigitString(offsetMagnitude % 60);
stringifiedSignature += " " + time + " " + sign + hours + minutes;
return stringifiedSignature;
};
+62
View File
@@ -0,0 +1,62 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = NodeGit.Utils.shallowClone;
var Stash = NodeGit.Stash;
var _apply = Stash.apply;
var _foreach = Stash.foreach;
var _pop = Stash.pop;
Stash.apply = function (repo, index, options) {
var checkoutOptions;
if (options) {
options = shallowClone(options);
checkoutOptions = options.checkoutOptions;
delete options.checkoutOptions;
} else {
options = {};
}
options = normalizeOptions(options, NodeGit.StashApplyOptions);
if (checkoutOptions) {
options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions);
}
return _apply(repo, index, options);
};
// Override Stash.foreach to eliminate the need to pass null payload
Stash.foreach = function (repo, callback) {
function wrappedCallback(index, message, oid) {
// We need to copy the OID since libgit2 types are getting cleaned up
// incorrectly right now in callbacks
return callback(index, message, oid.copy());
}
return _foreach(repo, wrappedCallback, null);
};
Stash.pop = function (repo, index, options) {
var checkoutOptions;
if (options) {
options = shallowClone(options);
checkoutOptions = options.checkoutOptions;
delete options.checkoutOptions;
} else {
options = {};
}
options = normalizeOptions(options, NodeGit.StashApplyOptions);
if (checkoutOptions) {
options.checkoutOptions = normalizeOptions(checkoutOptions, NodeGit.CheckoutOptions);
}
return _pop(repo, index, options);
};
+20
View File
@@ -0,0 +1,20 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var Status = NodeGit.Status;
var _foreach = Status.foreach;
var _foreachExt = Status.foreachExt;
// Override Status.foreach to eliminate the need to pass null payload
Status.foreach = function (repo, callback) {
return _foreach(repo, callback, null);
};
// Override Status.foreachExt to normalize opts
Status.foreachExt = function (repo, opts, callback) {
opts = normalizeOptions(opts, NodeGit.StatusOptions);
return _foreachExt(repo, opts, callback, null);
};
+95
View File
@@ -0,0 +1,95 @@
"use strict";
var NodeGit = require("../");
var Status = NodeGit.Status;
var StatusFile = function StatusFile(args) {
var path = args.path;
var status = args.status;
var entry = args.entry;
if (entry) {
status = entry.status();
if (entry.indexToWorkdir()) {
path = entry.indexToWorkdir().newFile().path();
} else {
path = entry.headToIndex().newFile().path();
}
}
var codes = Status.STATUS;
var getStatus = function getStatus() {
var fileStatuses = [];
for (var key in Status.STATUS) {
if (status & Status.STATUS[key]) {
fileStatuses.push(key);
}
}
return fileStatuses;
};
var data = {
path: path,
entry: entry,
statusBit: status,
statuses: getStatus()
};
return {
headToIndex: function headToIndex() {
if (data.entry) {
return entry.headToIndex();
} else {
return undefined;
}
},
indexToWorkdir: function indexToWorkdir() {
if (data.entry) {
return entry.indexToWorkdir();
} else {
return undefined;
}
},
inIndex: function inIndex() {
return status & codes.INDEX_NEW || status & codes.INDEX_MODIFIED || status & codes.INDEX_DELETED || status & codes.INDEX_TYPECHANGE || status & codes.INDEX_RENAMED;
},
inWorkingTree: function inWorkingTree() {
return status & codes.WT_NEW || status & codes.WT_MODIFIED || status & codes.WT_DELETED || status & codes.WT_TYPECHANGE || status & codes.WT_RENAMED;
},
isConflicted: function isConflicted() {
return status & codes.CONFLICTED;
},
isDeleted: function isDeleted() {
return status & codes.WT_DELETED || status & codes.INDEX_DELETED;
},
isIgnored: function isIgnored() {
return status & codes.IGNORED;
},
isModified: function isModified() {
return status & codes.WT_MODIFIED || status & codes.INDEX_MODIFIED;
},
isNew: function isNew() {
return status & codes.WT_NEW || status & codes.INDEX_NEW;
},
isRenamed: function isRenamed() {
return status & codes.WT_RENAMED || status & codes.INDEX_RENAMED;
},
isTypechange: function isTypechange() {
return status & codes.WT_TYPECHANGE || status & codes.INDEX_TYPECHANGE;
},
path: function path() {
return data.path;
},
status: function status() {
return data.statuses;
},
statusBit: function statusBit() {
return data.statusBit;
}
};
};
NodeGit.StatusFile = StatusFile;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
var NodeGit = require("../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var StatusList = NodeGit.StatusList;
var _create = StatusList.create;
// Override StatusList.create to normalize opts
StatusList.create = function (repo, opts) {
opts = normalizeOptions(opts, NodeGit.StatusOptions);
return _create(repo, opts);
};
+50
View File
@@ -0,0 +1,50 @@
"use strict";
var NodeGit = require("../");
var normalizeFetchOptions = NodeGit.Utils.normalizeFetchOptions;
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = NodeGit.Utils.shallowClone;
var Submodule = NodeGit.Submodule;
var _foreach = Submodule.foreach;
var _update = Submodule.prototype.update;
// Override Submodule.foreach to eliminate the need to pass null payload
Submodule.foreach = function (repo, callback) {
return _foreach(repo, callback, null);
};
/**
* Updates a submodule
*
* @async
* @param {Number} init Setting this to 1 will initialize submodule
* before updating
* @param {SubmoduleUpdateOptions} options Submodule update settings
* @return {Number} 0 on success, any non-zero return value from a callback
*/
Submodule.prototype.update = function (init, options) {
var fetchOpts;
var checkoutOpts;
if (options) {
options = shallowClone(options);
fetchOpts = options.fetchOpts;
checkoutOpts = options.checkoutOpts;
delete options.fetchOpts;
delete options.checkoutOpts;
}
options = normalizeOptions(options, NodeGit.SubmoduleUpdateOptions);
if (fetchOpts) {
options.fetchOpts = normalizeFetchOptions(fetchOpts);
}
if (checkoutOpts) {
options.checkoutOpts = normalizeOptions(checkoutOpts, NodeGit.CheckoutOptions);
}
return _update.call(this, init, options);
};
+134
View File
@@ -0,0 +1,134 @@
"use strict";
var NodeGit = require("../");
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var Tag = NodeGit.Tag;
var signatureRegexesBySignatureType = {
gpgsig: [/-----BEGIN PGP SIGNATURE-----[\s\S]+?-----END PGP SIGNATURE-----/gm, /-----BEGIN PGP MESSAGE-----[\s\S]+?-----END PGP MESSAGE-----/gm],
x509: [/-----BEGIN SIGNED MESSAGE-----[\s\S]+?-----END SIGNED MESSAGE-----/gm]
};
/**
* Retrieves the tag pointed to by the oid
* @async
* @param {Repository} repo The repo that the tag lives in
* @param {String|Oid|Tag} id The tag to lookup
* @return {Tag}
*/
Tag.lookup = LookupWrapper(Tag);
/**
* @async
* @param {Repository} repo
* @param {String} tagName
* @param {Oid} target
* @param {Signature} tagger
* @return {String}
*/
Tag.createBuffer = function (repo, tagName, target, tagger, message) {
return NodeGit.Object.lookup(repo, target, NodeGit.Object.TYPE.ANY).then(function (object) {
if (!NodeGit.Object.typeisloose(object.type())) {
throw new Error("Object must be a loose type");
}
var id = object.id().toString();
var objectType = NodeGit.Object.type2String(object.type());
var lines = ["object " + id, "type " + objectType, "tag " + tagName, "tagger " + tagger.toString(true) + "\n", "" + message + (message.endsWith("\n") ? "" : "\n")];
return lines.join("\n");
});
};
/**
* @async
* @param {Repository} repo
* @param {String} tagName
* @param {Oid} target
* @param {Signature} tagger
* @param {String} message
* @param {Number} force
* @param {Function} signingCallback Takes a string and returns a string
* representing the signed message
* @return {Oid}
*/
Tag.createWithSignature = function (repo, tagName, target, tagger, message, force, signingCallback) {
var tagBuffer = void 0;
return Tag.createBuffer(repo, tagName, target, tagger, message).then(function (tagBufferResult) {
tagBuffer = tagBufferResult;
return signingCallback(tagBuffer);
}).then(function (_ref) {
var code = _ref.code,
signedData = _ref.signedData;
switch (code) {
case NodeGit.Error.CODE.OK:
{
var normalizedEnding = signedData.endsWith("\n") ? "" : "\n";
var signedTagString = tagBuffer + signedData + normalizedEnding;
return Tag.createFromBuffer(repo, signedTagString, force);
}
case NodeGit.Error.CODE.PASSTHROUGH:
return Tag.create(repo, tagName, target, tagger, message, force);
default:
{
var error = new Error("Tag.createWithSignature threw with error code " + code);
error.errno = code;
throw error;
}
}
});
};
/**
* Retrieves the signature of an annotated tag
* @async
* @param {String} signatureType
* @return {String|null}
*/
Tag.prototype.extractSignature = function () {
var signatureType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "gpgsig";
var id = this.id();
var repo = this.repo;
var signatureRegexes = signatureRegexesBySignatureType[signatureType];
if (!signatureRegexes) {
throw new Error("Unsupported signature type");
}
return repo.odb().then(function (odb) {
return odb.read(id);
}).then(function (odbObject) {
var odbData = odbObject.toString();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = signatureRegexes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var regex = _step.value;
var matchResult = odbData.match(regex);
if (matchResult !== null) {
return matchResult[0];
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
throw new Error("this tag is not signed");
});
};
+178
View File
@@ -0,0 +1,178 @@
"use strict";
var path = require("path");
var events = require("events");
var NodeGit = require("../");
var Diff = NodeGit.Diff;
var LookupWrapper = NodeGit.Utils.lookupWrapper;
var Tree = NodeGit.Tree;
var Treebuilder = NodeGit.Treebuilder;
/**
* Retrieves the tree pointed to by the oid
* @async
* @param {Repository} repo The repo that the tree lives in
* @param {String|Oid|Tree} id The tree to lookup
* @return {Tree}
*/
Tree.lookup = LookupWrapper(Tree);
/**
* Make builder. This is helpful for modifying trees.
* @return {Treebuilder}
*/
Tree.prototype.builder = function () {
var builder = Treebuilder.create(this);
builder.root = builder;
builder.repo = this.repo;
return builder;
};
/**
* Diff two trees
* @async
* @param {Tree} tree to diff against
* @return {Diff}
*/
Tree.prototype.diff = function (tree) {
return this.diffWithOptions(tree, null);
};
/**
* Diff two trees with options
* @async
* @param {Tree} tree to diff against
* @param {Object} options
* @return {Diff}
*/
Tree.prototype.diffWithOptions = function (tree, options) {
return Diff.treeToTree(this.repo, tree, this, options);
};
/**
* Return an array of the entries in this tree (excluding its children).
* @return {Array<TreeEntry>} an array of TreeEntrys
*/
Tree.prototype.entries = function () {
var size = this.entryCount();
var result = [];
for (var i = 0; i < size; i++) {
result.push(this.entryByIndex(i));
}
return result;
};
/**
* Get an entry at the ith position.
*
* @param {Number} i
* @return {TreeEntry}
*/
Tree.prototype.entryByIndex = function (i) {
var entry = this._entryByIndex(i);
entry.parent = this;
return entry;
};
/**
* Get an entry by name; if the tree is a directory, the name is the filename.
*
* @param {String} name
* @return {TreeEntry}
*/
Tree.prototype.entryByName = function (name) {
var entry = this._entryByName(name);
entry.parent = this;
return entry;
};
/**
* Get an entry at a path. Unlike by name, this takes a fully
* qualified path, like `/foo/bar/baz.javascript`
* @async
* @param {String} filePath
* @return {TreeEntry}
*/
Tree.prototype.getEntry = function (filePath) {
var tree = this;
return this.entryByPath(filePath).then(function (entry) {
entry.parent = tree;
entry.dirtoparent = path.dirname(filePath);
return entry;
});
};
/**
* Return the path of this tree, like `/lib/foo/bar`
* @return {String}
*/
Tree.prototype.path = function (blobsOnly) {
return this.entry ? this.entry.path() : "";
};
/**
* Recursively walk the tree in breadth-first order. Fires an event for each
* entry.
*
* @fires EventEmitter#entry Tree
* @fires EventEmitter#end Array<Tree>
* @fires EventEmitter#error Error
*
* @param {Boolean} [blobsOnly = true] True to emit only blob & blob executable
* entries.
*
* @return {EventEmitter}
*/
Tree.prototype.walk = function (blobsOnly) {
blobsOnly = typeof blobsOnly === "boolean" ? blobsOnly : true;
var self = this;
var event = new events.EventEmitter();
var total = 1;
var entries = new Set();
var finalEntires = [];
// This looks like a DFS, but it is a BFS because of implicit queueing in
// the recursive call to `entry.getTree(bfs)`
function bfs(error, tree) {
total--;
if (error) {
return event.emit("error", error);
}
tree.entries().forEach(function (entry, entryIndex) {
if (!blobsOnly || entry.isFile() && !entries.has(entry)) {
event.emit("entry", entry);
entries.add(entry);
// Node 0.12 doesn't support either [v for (v of entries)] nor
// Array.from so we'll just maintain our own list.
finalEntires.push(entry);
}
if (entry.isTree()) {
total++;
entry.getTree().then(function (result) {
return bfs(null, result);
}, bfs);
}
});
if (total === 0) {
event.emit("end", finalEntires);
}
}
event.start = function () {
bfs(null, self);
};
return event;
};
+100
View File
@@ -0,0 +1,100 @@
"use strict";
var path = require("path").posix;
var NodeGit = require("../");
var TreeEntry = NodeGit.TreeEntry;
/**
* Retrieve the blob for this entry. Make sure to call `isBlob` first!
* @async
* @return {Blob}
*/
TreeEntry.prototype.getBlob = function () {
return this.parent.repo.getBlob(this.id());
};
/**
* Retrieve the tree for this entry. Make sure to call `isTree` first!
* @async
* @return {Tree}
*/
TreeEntry.prototype.getTree = function () {
var entry = this;
return this.parent.repo.getTree(this.id()).then(function (tree) {
tree.entry = entry;
return tree;
});
};
/**
* Is this TreeEntry a blob? Alias for `isFile`
* @return {Boolean}
*/
TreeEntry.prototype.isBlob = function () {
return this.isFile();
};
/**
* Is this TreeEntry a directory? Alias for `isTree`
* @return {Boolean}
*/
TreeEntry.prototype.isDirectory = function () {
return this.isTree();
};
/**
* Is this TreeEntry a blob? (i.e., a file)
* @return {Boolean}
*/
TreeEntry.prototype.isFile = function () {
return this.filemode() === TreeEntry.FILEMODE.BLOB || this.filemode() === TreeEntry.FILEMODE.EXECUTABLE;
};
/**
* Is this TreeEntry a submodule?
* @return {Boolean}
*/
TreeEntry.prototype.isSubmodule = function () {
return this.filemode() === TreeEntry.FILEMODE.COMMIT;
};
/**
* Is this TreeEntry a tree? (i.e., a directory)
* @return {Boolean}
*/
TreeEntry.prototype.isTree = function () {
return this.filemode() === TreeEntry.FILEMODE.TREE;
};
/**
* Retrieve the SHA for this TreeEntry. Alias for `sha`
* @return {String}
*/
TreeEntry.prototype.oid = function () {
return this.sha();
};
/**
* Returns the path for this entry.
* @return {String}
*/
TreeEntry.prototype.path = function () {
var dirtoparent = this.dirtoparent || "";
return path.join(this.parent.path(), dirtoparent, this.name());
};
/**
* Retrieve the SHA for this TreeEntry.
* @return {String}
*/
TreeEntry.prototype.sha = function () {
return this.id().toString();
};
/**
* Alias for `path`
*/
TreeEntry.prototype.toString = function () {
return this.path();
};
+41
View File
@@ -0,0 +1,41 @@
"use strict";
var NodeGit = require("../../");
/**
* Wraps a method so that you can pass in either a string, OID or the object
* itself and you will always get back a promise that resolves to the object.
* @param {Object} objectType The object type that you're expecting to receive.
* @param {Function} lookupFunction The function to do the lookup for the
* object. Defaults to `objectType.lookup`.
* @return {Function}
*/
function lookupWrapper(objectType, lookupFunction) {
lookupFunction = lookupFunction || objectType.lookup;
return function (repo, id, callback) {
if (id instanceof objectType) {
return Promise.resolve(id).then(function (obj) {
obj.repo = repo;
if (typeof callback === "function") {
callback(null, obj);
}
return obj;
}, callback);
}
return lookupFunction(repo, id).then(function (obj) {
obj.repo = repo;
if (typeof callback === "function") {
callback(null, obj);
}
return obj;
}, callback);
};
}
NodeGit.Utils.lookupWrapper = lookupWrapper;
+43
View File
@@ -0,0 +1,43 @@
"use strict";
var NodeGit = require("../../");
var normalizeOptions = NodeGit.Utils.normalizeOptions;
var shallowClone = NodeGit.Utils.shallowClone;
/**
* Normalize an object to match a struct.
*
* @param {String, Object} oid - The oid string or instance.
* @return {Object} An Oid instance.
*/
function normalizeFetchOptions(options) {
if (options instanceof NodeGit.FetchOptions) {
return options;
}
var callbacks;
var proxyOpts;
if (options) {
options = shallowClone(options);
callbacks = options.callbacks;
proxyOpts = options.proxyOpts;
delete options.callbacks;
delete options.proxyOpts;
} else {
options = {};
}
options = normalizeOptions(options, NodeGit.FetchOptions);
if (callbacks) {
options.callbacks = normalizeOptions(callbacks, NodeGit.RemoteCallbacks);
}
if (proxyOpts) {
options.proxyOpts = normalizeOptions(proxyOpts, NodeGit.ProxyOptions);
}
return options;
}
NodeGit.Utils.normalizeFetchOptions = normalizeFetchOptions;
+31
View File
@@ -0,0 +1,31 @@
"use strict";
var NodeGit = require("../../");
/**
* Normalize an object to match a struct.
*
* @param {String, Object} oid - The oid string or instance.
* @return {Object} An Oid instance.
*/
function normalizeOptions(options, Ctor) {
if (!options) {
return null;
}
if (options instanceof Ctor) {
return options;
}
var instance = new Ctor();
Object.keys(options).forEach(function (key) {
if (typeof options[key] !== "undefined") {
instance[key] = options[key];
}
});
return instance;
}
NodeGit.Utils.normalizeOptions = normalizeOptions;
+16
View File
@@ -0,0 +1,16 @@
"use strict";
var NodeGit = require("../../");
function shallowClone() {
var merges = Array.prototype.slice.call(arguments);
return merges.reduce(function (obj, merge) {
return Object.keys(merge).reduce(function (obj, key) {
obj[key] = merge[key];
return obj;
}, obj);
}, {});
}
NodeGit.Utils.shallowClone = shallowClone;
+180
View File
@@ -0,0 +1,180 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITANNOTATEDCOMMIT_H
#define GITANNOTATEDCOMMIT_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/oid.h"
#include "../include/reference.h"
// Forward declaration.
struct git_annotated_commit {
};
using namespace node;
using namespace v8;
class GitAnnotatedCommit;
struct GitAnnotatedCommitTraits {
typedef GitAnnotatedCommit cppClass;
typedef git_annotated_commit cType;
static const bool isDuplicable = false;
static void duplicate(git_annotated_commit **dest, git_annotated_commit *src) {
Nan::ThrowError("duplicate called on GitAnnotatedCommit which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_annotated_commit *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_annotated_commit_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitAnnotatedCommit : public
NodeGitWrapper<GitAnnotatedCommitTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitAnnotatedCommitTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitAnnotatedCommit()
: NodeGitWrapper<GitAnnotatedCommitTraits>(
"A new GitAnnotatedCommit cannot be instantiated."
)
{}
GitAnnotatedCommit(git_annotated_commit *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitAnnotatedCommitTraits>(raw, selfFreeing, owner)
{}
~GitAnnotatedCommit();
struct FromFetchheadBaton {
int error_code;
const git_error* error;
git_annotated_commit * out;
git_repository * repo;
const char * branch_name;
const char * remote_url;
const git_oid * id;
bool idNeedsFree;
};
class FromFetchheadWorker : public Nan::AsyncWorker {
public:
FromFetchheadWorker(
FromFetchheadBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FromFetchheadWorker() {};
void Execute();
void HandleOKCallback();
private:
FromFetchheadBaton *baton;
};
static NAN_METHOD(FromFetchhead);
struct FromRefBaton {
int error_code;
const git_error* error;
git_annotated_commit * out;
git_repository * repo;
const git_reference * ref;
};
class FromRefWorker : public Nan::AsyncWorker {
public:
FromRefWorker(
FromRefBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FromRefWorker() {};
void Execute();
void HandleOKCallback();
private:
FromRefBaton *baton;
};
static NAN_METHOD(FromRef);
struct FromRevspecBaton {
int error_code;
const git_error* error;
git_annotated_commit * out;
git_repository * repo;
const char * revspec;
};
class FromRevspecWorker : public Nan::AsyncWorker {
public:
FromRevspecWorker(
FromRevspecBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FromRevspecWorker() {};
void Execute();
void HandleOKCallback();
private:
FromRevspecBaton *baton;
};
static NAN_METHOD(FromRevspec);
static NAN_METHOD(Id);
struct LookupBaton {
int error_code;
const git_error* error;
git_annotated_commit * out;
git_repository * repo;
const git_oid * id;
bool idNeedsFree;
};
class LookupWorker : public Nan::AsyncWorker {
public:
LookupWorker(
LookupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupBaton *baton;
};
static NAN_METHOD(Lookup);
static NAN_METHOD(Ref);
};
#endif
+72
View File
@@ -0,0 +1,72 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITAPPLY_H
#define GITAPPLY_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/diff.h"
#include "../include/apply_options.h"
#include "../include/index.h"
#include "../include/tree.h"
using namespace node;
using namespace v8;
class GitApply : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
static NAN_METHOD(Apply);
struct ToTreeBaton {
int error_code;
const git_error* error;
git_index * out;
git_repository * repo;
git_tree * preimage;
git_diff * diff;
const git_apply_options * options;
};
class ToTreeWorker : public Nan::AsyncWorker {
public:
ToTreeWorker(
ToTreeBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~ToTreeWorker() {};
void Execute();
void HandleOKCallback();
private:
ToTreeBaton *baton;
};
static NAN_METHOD(ToTree);
};
#endif
+114
View File
@@ -0,0 +1,114 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITAPPLYOPTIONS_H
#define GITAPPLYOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/diff_delta.h"
#include "../include/diff_hunk.h"
using namespace node;
using namespace v8;
class GitApplyOptions;
struct GitApplyOptionsTraits {
typedef GitApplyOptions cppClass;
typedef git_apply_options cType;
static const bool isDuplicable = false;
static void duplicate(git_apply_options **dest, git_apply_options *src) {
Nan::ThrowError("duplicate called on GitApplyOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = false;
static void free(git_apply_options *raw) {
Nan::ThrowError("free called on GitApplyOptions which cannot be freed");
}
};
class GitApplyOptions : public NodeGitWrapper<GitApplyOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitApplyOptionsTraits>;
public:
GitApplyOptions(git_apply_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
static int delta_cb_cppCallback (
const git_diff_delta * delta
,
void * payload
);
static void delta_cb_async(void *baton);
static void delta_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct DeltaCbBaton : public AsyncBatonWithResult<int> {
const git_diff_delta * delta;
void * payload;
DeltaCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitApplyOptions * delta_cb_getInstanceFromBaton (
DeltaCbBaton *baton);
static int hunk_cb_cppCallback (
const git_diff_hunk * hunk
,
void * payload
);
static void hunk_cb_async(void *baton);
static void hunk_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct HunkCbBaton : public AsyncBatonWithResult<int> {
const git_diff_hunk * hunk;
void * payload;
HunkCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitApplyOptions * hunk_cb_getInstanceFromBaton (
HunkCbBaton *baton);
private:
GitApplyOptions();
~GitApplyOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
CallbackWrapper delta_cb;
static NAN_GETTER(GetDeltaCb);
static NAN_SETTER(SetDeltaCb);
CallbackWrapper hunk_cb;
static NAN_GETTER(GetHunkCb);
static NAN_SETTER(SetHunkCb);
Nan::Persistent<Value> payload;
static NAN_GETTER(GetPayload);
static NAN_SETTER(SetPayload);
};
#endif
+97
View File
@@ -0,0 +1,97 @@
#ifndef ASYNC_BATON
#define ASYNC_BATON
#include <uv.h>
#include <nan.h>
#include "lock_master.h"
#include "nodegit.h"
// Base class for Batons used for callbacks (for example,
// JS functions passed as callback parameters,
// or field properties of configuration objects whose values are callbacks)
struct AsyncBaton {
uv_sem_t semaphore;
virtual ~AsyncBaton() {}
};
void deleteBaton(AsyncBaton *baton);
template<typename ResultT>
struct AsyncBatonWithResult : public AsyncBaton {
ResultT result;
ResultT defaultResult; // result returned if the callback doesn't return anything valid
void (*onCompletion)(AsyncBaton *);
AsyncBatonWithResult(const ResultT &defaultResult)
: defaultResult(defaultResult) {
}
void Done() {
if (onCompletion) {
onCompletion(this);
} else {
// signal completion
uv_sem_post(&semaphore);
}
}
ResultT ExecuteAsync(ThreadPool::Callback asyncCallback, void (*onCompletion)(AsyncBaton *) = NULL) {
result = 0;
this->onCompletion = onCompletion;
if (!onCompletion) {
uv_sem_init(&semaphore, 0);
}
{
LockMaster::TemporaryUnlock temporaryUnlock;
libgit2ThreadPool.ExecuteReverseCallback(asyncCallback, this);
if (!onCompletion) {
// wait for completion
uv_sem_wait(&semaphore);
uv_sem_destroy(&semaphore);
}
}
return result;
}
};
struct AsyncBatonWithNoResult : public AsyncBaton {
void (*onCompletion)(AsyncBaton *);
void Done() {
if (onCompletion) {
onCompletion(this);
} else {
// signal completion
uv_sem_post(&semaphore);
}
}
void ExecuteAsync(ThreadPool::Callback asyncCallback, void (*onCompletion)(AsyncBaton *) = NULL) {
this->onCompletion = onCompletion;
if (!onCompletion) {
uv_sem_init(&semaphore, 0);
}
{
LockMaster::TemporaryUnlock temporaryUnlock;
libgit2ThreadPool.ExecuteReverseCallback(asyncCallback, this);
if (!onCompletion) {
// wait for completion
uv_sem_wait(&semaphore);
uv_sem_destroy(&semaphore);
}
}
return;
}
};
#endif
+33
View File
@@ -0,0 +1,33 @@
#ifndef ASYNC_LIBGIT2_QUEUE_WORKER_H
#define ASYNC_LIBGIT2_QUEUE_WORKER_H
#include <nan.h>
#include <uv.h>
#include "../include/thread_pool.h"
#include "../include/nodegit.h"
// Runs WorkComplete of the scheduled AsyncWorker,
// and destroys it. This is run in the uv_default_loop event loop.
NAN_INLINE void AsyncLibgit2Complete (void* data) {
Nan::AsyncWorker *worker = static_cast<Nan::AsyncWorker*>(data);
worker->WorkComplete();
worker->Destroy();
}
// Runs Execute of the scheduled AyncWorker on the dedicated libgit2 thread /
// event loop, and schedules the WorkComplete callback to run on the
// uv_default_loop event loop
NAN_INLINE void AsyncLibgit2Execute (void *vworker) {
// execute the worker
Nan::AsyncWorker *worker = static_cast<Nan::AsyncWorker*>(vworker);
worker->Execute();
}
// Schedules the AsyncWorker to run on the dedicated libgit2 thread / event loop,
// and on completion AsyncLibgit2Complete on the default loop
NAN_INLINE void AsyncLibgit2QueueWorker (Nan::AsyncWorker* worker) {
libgit2ThreadPool.QueueWork(AsyncLibgit2Execute, AsyncLibgit2Complete, worker);
}
#endif
+99
View File
@@ -0,0 +1,99 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITATTR_H
#define GITATTR_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
using namespace node;
using namespace v8;
class GitAttr : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
static NAN_METHOD(AddMacro);
static NAN_METHOD(CacheFlush);
struct GetBaton {
int error_code;
const git_error* error;
const char * value_out;
git_repository * repo;
uint32_t flags;
const char * path;
const char * name;
};
class GetWorker : public Nan::AsyncWorker {
public:
GetWorker(
GetBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetWorker() {};
void Execute();
void HandleOKCallback();
private:
GetBaton *baton;
};
static NAN_METHOD(Get);
struct GetManyBaton {
int error_code;
const git_error* error;
const char * values_out;
git_repository * repo;
uint32_t flags;
const char * path;
size_t num_attr;
const char ** names;
};
class GetManyWorker : public Nan::AsyncWorker {
public:
GetManyWorker(
GetManyBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetManyWorker() {};
void Execute();
void HandleOKCallback();
private:
GetManyBaton *baton;
};
static NAN_METHOD(GetMany);
static NAN_METHOD(Value);
};
#endif
+132
View File
@@ -0,0 +1,132 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBLAME_H
#define GITBLAME_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/blame_options.h"
#include "../include/blame_hunk.h"
// Forward declaration.
struct git_blame {
};
using namespace node;
using namespace v8;
class GitBlame;
struct GitBlameTraits {
typedef GitBlame cppClass;
typedef git_blame cType;
static const bool isDuplicable = false;
static void duplicate(git_blame **dest, git_blame *src) {
Nan::ThrowError("duplicate called on GitBlame which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_blame *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_blame_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBlame : public
NodeGitWrapper<GitBlameTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitBlameTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBlame()
: NodeGitWrapper<GitBlameTraits>(
"A new GitBlame cannot be instantiated."
)
{}
GitBlame(git_blame *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitBlameTraits>(raw, selfFreeing, owner)
{}
~GitBlame();
struct BufferBaton {
int error_code;
const git_error* error;
git_blame * out;
git_blame * reference;
const char * buffer;
size_t buffer_len;
};
class BufferWorker : public Nan::AsyncWorker {
public:
BufferWorker(
BufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~BufferWorker() {};
void Execute();
void HandleOKCallback();
private:
BufferBaton *baton;
};
static NAN_METHOD(Buffer);
struct FileBaton {
int error_code;
const git_error* error;
git_blame * out;
git_repository * repo;
const char * path;
git_blame_options * options;
};
class FileWorker : public Nan::AsyncWorker {
public:
FileWorker(
FileBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FileWorker() {};
void Execute();
void HandleOKCallback();
private:
FileBaton *baton;
};
static NAN_METHOD(File);
static NAN_METHOD(GetHunkByindex);
static NAN_METHOD(GetHunkByline);
static NAN_METHOD(GetHunkCount);
};
#endif
+80
View File
@@ -0,0 +1,80 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBLAMEHUNK_H
#define GITBLAMEHUNK_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/oid.h"
#include "../include/signature.h"
using namespace node;
using namespace v8;
class GitBlameHunk;
struct GitBlameHunkTraits {
typedef GitBlameHunk cppClass;
typedef git_blame_hunk cType;
static const bool isDuplicable = false;
static void duplicate(git_blame_hunk **dest, git_blame_hunk *src) {
Nan::ThrowError("duplicate called on GitBlameHunk which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_blame_hunk *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBlameHunk : public
NodeGitWrapper<GitBlameHunkTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitBlameHunkTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBlameHunk()
: NodeGitWrapper<GitBlameHunkTraits>(
"A new GitBlameHunk cannot be instantiated."
)
{}
GitBlameHunk(git_blame_hunk *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitBlameHunkTraits>(raw, selfFreeing, owner)
{}
~GitBlameHunk();
static NAN_METHOD(LinesInHunk);
static NAN_METHOD(FinalCommitId);
static NAN_METHOD(FinalStartLineNumber);
static NAN_METHOD(FinalSignature);
static NAN_METHOD(OrigCommitId);
static NAN_METHOD(OrigPath);
static NAN_METHOD(OrigStartLineNumber);
static NAN_METHOD(OrigSignature);
};
#endif
+91
View File
@@ -0,0 +1,91 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITBLAMEOPTIONS_H
#define GITBLAMEOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/oid.h"
using namespace node;
using namespace v8;
class GitBlameOptions;
struct GitBlameOptionsTraits {
typedef GitBlameOptions cppClass;
typedef git_blame_options cType;
static const bool isDuplicable = false;
static void duplicate(git_blame_options **dest, git_blame_options *src) {
Nan::ThrowError("duplicate called on GitBlameOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_blame_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBlameOptions : public NodeGitWrapper<GitBlameOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitBlameOptionsTraits>;
public:
GitBlameOptions(git_blame_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBlameOptions();
~GitBlameOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetFlags);
static NAN_SETTER(SetFlags);
static NAN_GETTER(GetMinMatchCharacters);
static NAN_SETTER(SetMinMatchCharacters);
Nan::Persistent<Object> newest_commit;
static NAN_GETTER(GetNewestCommit);
static NAN_SETTER(SetNewestCommit);
Nan::Persistent<Object> oldest_commit;
static NAN_GETTER(GetOldestCommit);
static NAN_SETTER(SetOldestCommit);
static NAN_GETTER(GetMinLine);
static NAN_SETTER(SetMinLine);
static NAN_GETTER(GetMaxLine);
static NAN_SETTER(SetMaxLine);
};
#endif
+286
View File
@@ -0,0 +1,286 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBLOB_H
#define GITBLOB_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/wrapper.h"
#include "node_buffer.h"
#include "../include/oid.h"
#include "../include/repository.h"
#include "../include/buf.h"
#include "../include/blob_filter_options.h"
// Forward declaration.
struct git_blob {
};
using namespace node;
using namespace v8;
class GitBlob;
struct GitBlobTraits {
typedef GitBlob cppClass;
typedef git_blob cType;
static const bool isDuplicable = false;
static void duplicate(git_blob **dest, git_blob *src) {
Nan::ThrowError("duplicate called on GitBlob which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_blob *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_blob_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBlob : public
NodeGitWrapper<GitBlobTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitBlobTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBlob()
: NodeGitWrapper<GitBlobTraits>(
"A new GitBlob cannot be instantiated."
)
{}
GitBlob(git_blob *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitBlobTraits>(raw, selfFreeing, owner)
{}
~GitBlob();
struct CreateFromBufferBaton {
int error_code;
const git_error* error;
git_oid * id;
git_repository * repo;
const void * buffer;
size_t len;
};
class CreateFromBufferWorker : public Nan::AsyncWorker {
public:
CreateFromBufferWorker(
CreateFromBufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateFromBufferWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateFromBufferBaton *baton;
};
static NAN_METHOD(CreateFromBuffer);
struct CreateFromDiskBaton {
int error_code;
const git_error* error;
git_oid * id;
git_repository * repo;
const char * path;
};
class CreateFromDiskWorker : public Nan::AsyncWorker {
public:
CreateFromDiskWorker(
CreateFromDiskBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateFromDiskWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateFromDiskBaton *baton;
};
static NAN_METHOD(CreateFromDisk);
struct CreateFromWorkdirBaton {
int error_code;
const git_error* error;
git_oid * id;
git_repository * repo;
const char * relative_path;
};
class CreateFromWorkdirWorker : public Nan::AsyncWorker {
public:
CreateFromWorkdirWorker(
CreateFromWorkdirBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateFromWorkdirWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateFromWorkdirBaton *baton;
};
static NAN_METHOD(CreateFromWorkdir);
struct DupBaton {
int error_code;
const git_error* error;
git_blob * out;
git_blob * source;
};
class DupWorker : public Nan::AsyncWorker {
public:
DupWorker(
DupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~DupWorker() {};
void Execute();
void HandleOKCallback();
private:
DupBaton *baton;
};
static NAN_METHOD(Dup);
struct FilterBaton {
int error_code;
const git_error* error;
git_buf * out;
git_blob * blob;
const char * as_path;
git_blob_filter_options * opts;
};
class FilterWorker : public Nan::AsyncWorker {
public:
FilterWorker(
FilterBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FilterWorker() {};
void Execute();
void HandleOKCallback();
private:
FilterBaton *baton;
};
static NAN_METHOD(Filter);
struct FilteredContentBaton {
int error_code;
const git_error* error;
git_buf * out;
git_blob * blob;
const char * as_path;
int check_for_binary_data;
};
class FilteredContentWorker : public Nan::AsyncWorker {
public:
FilteredContentWorker(
FilteredContentBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FilteredContentWorker() {};
void Execute();
void HandleOKCallback();
private:
FilteredContentBaton *baton;
};
static NAN_METHOD(FilteredContent);
static NAN_METHOD(Id);
static NAN_METHOD(IsBinary);
struct LookupBaton {
int error_code;
const git_error* error;
git_blob * blob;
git_repository * repo;
const git_oid * id;
bool idNeedsFree;
};
class LookupWorker : public Nan::AsyncWorker {
public:
LookupWorker(
LookupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupBaton *baton;
};
static NAN_METHOD(Lookup);
struct LookupPrefixBaton {
int error_code;
const git_error* error;
git_blob * blob;
git_repository * repo;
const git_oid * id;
bool idNeedsFree;
size_t len;
};
class LookupPrefixWorker : public Nan::AsyncWorker {
public:
LookupPrefixWorker(
LookupPrefixBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupPrefixWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupPrefixBaton *baton;
};
static NAN_METHOD(LookupPrefix);
static NAN_METHOD(Owner);
static NAN_METHOD(Rawcontent);
static NAN_METHOD(Rawsize);
};
#endif
+68
View File
@@ -0,0 +1,68 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITBLOBFILTEROPTIONS_H
#define GITBLOBFILTEROPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
using namespace node;
using namespace v8;
class GitBlobFilterOptions;
struct GitBlobFilterOptionsTraits {
typedef GitBlobFilterOptions cppClass;
typedef git_blob_filter_options cType;
static const bool isDuplicable = false;
static void duplicate(git_blob_filter_options **dest, git_blob_filter_options *src) {
Nan::ThrowError("duplicate called on GitBlobFilterOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_blob_filter_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBlobFilterOptions : public NodeGitWrapper<GitBlobFilterOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitBlobFilterOptionsTraits>;
public:
GitBlobFilterOptions(git_blob_filter_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBlobFilterOptions();
~GitBlobFilterOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetFlags);
static NAN_SETTER(SetFlags);
};
#endif
+272
View File
@@ -0,0 +1,272 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBRANCH_H
#define GITBRANCH_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/buf.h"
#include "../include/reference.h"
#include "../include/repository.h"
#include "../include/commit.h"
#include "../include/annotated_commit.h"
#include "../include/buf.h"
using namespace node;
using namespace v8;
class GitBranch : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
struct CreateBaton {
int error_code;
const git_error* error;
git_reference * out;
git_repository * repo;
const char * branch_name;
const git_commit * target;
int force;
};
class CreateWorker : public Nan::AsyncWorker {
public:
CreateWorker(
CreateBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateBaton *baton;
};
static NAN_METHOD(Create);
struct CreateFromAnnotatedBaton {
int error_code;
const git_error* error;
git_reference * ref_out;
git_repository * repository;
const char * branch_name;
const git_annotated_commit * commit;
int force;
};
class CreateFromAnnotatedWorker : public Nan::AsyncWorker {
public:
CreateFromAnnotatedWorker(
CreateFromAnnotatedBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateFromAnnotatedWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateFromAnnotatedBaton *baton;
};
static NAN_METHOD(CreateFromAnnotated);
static NAN_METHOD(Delete);
static NAN_METHOD(IsCheckedOut);
static NAN_METHOD(IsHead);
struct LookupBaton {
int error_code;
const git_error* error;
git_reference * out;
git_repository * repo;
const char * branch_name;
git_branch_t branch_type;
};
class LookupWorker : public Nan::AsyncWorker {
public:
LookupWorker(
LookupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupBaton *baton;
};
static NAN_METHOD(Lookup);
struct MoveBaton {
int error_code;
const git_error* error;
git_reference * out;
git_reference * branch;
const char * new_branch_name;
int force;
};
class MoveWorker : public Nan::AsyncWorker {
public:
MoveWorker(
MoveBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~MoveWorker() {};
void Execute();
void HandleOKCallback();
private:
MoveBaton *baton;
};
static NAN_METHOD(Move);
struct NameBaton {
int error_code;
const git_error* error;
const char * out;
const git_reference * ref;
};
class NameWorker : public Nan::AsyncWorker {
public:
NameWorker(
NameBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~NameWorker() {};
void Execute();
void HandleOKCallback();
private:
NameBaton *baton;
};
static NAN_METHOD(Name);
struct RemoteNameBaton {
int error_code;
const git_error* error;
git_buf * out;
git_repository * repo;
const char * refname;
};
class RemoteNameWorker : public Nan::AsyncWorker {
public:
RemoteNameWorker(
RemoteNameBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~RemoteNameWorker() {};
void Execute();
void HandleOKCallback();
private:
RemoteNameBaton *baton;
};
static NAN_METHOD(RemoteName);
struct SetUpstreamBaton {
int error_code;
const git_error* error;
git_reference * branch;
const char * branch_name;
};
class SetUpstreamWorker : public Nan::AsyncWorker {
public:
SetUpstreamWorker(
SetUpstreamBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetUpstreamWorker() {};
void Execute();
void HandleOKCallback();
private:
SetUpstreamBaton *baton;
};
static NAN_METHOD(SetUpstream);
struct UpstreamBaton {
int error_code;
const git_error* error;
git_reference * out;
const git_reference * branch;
};
class UpstreamWorker : public Nan::AsyncWorker {
public:
UpstreamWorker(
UpstreamBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~UpstreamWorker() {};
void Execute();
void HandleOKCallback();
private:
UpstreamBaton *baton;
};
static NAN_METHOD(Upstream);
struct UpstreamNameBaton {
int error_code;
const git_error* error;
git_buf * out;
git_repository * repo;
const char * refname;
};
class UpstreamNameWorker : public Nan::AsyncWorker {
public:
UpstreamNameWorker(
UpstreamNameBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~UpstreamNameWorker() {};
void Execute();
void HandleOKCallback();
private:
UpstreamNameBaton *baton;
};
static NAN_METHOD(UpstreamName);
static NAN_METHOD(UpstreamRemote);
};
#endif
+73
View File
@@ -0,0 +1,73 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBRANCHITERATOR_H
#define GITBRANCHITERATOR_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
// Forward declaration.
struct git_branch_iterator {
};
using namespace node;
using namespace v8;
class GitBranchIterator;
struct GitBranchIteratorTraits {
typedef GitBranchIterator cppClass;
typedef git_branch_iterator cType;
static const bool isDuplicable = false;
static void duplicate(git_branch_iterator **dest, git_branch_iterator *src) {
Nan::ThrowError("duplicate called on GitBranchIterator which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_branch_iterator *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitBranchIterator : public
NodeGitWrapper<GitBranchIteratorTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitBranchIteratorTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBranchIterator()
: NodeGitWrapper<GitBranchIteratorTraits>(
"A new GitBranchIterator cannot be instantiated."
)
{}
GitBranchIterator(git_branch_iterator *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitBranchIteratorTraits>(raw, selfFreeing, owner)
{}
~GitBranchIterator();
};
#endif
+84
View File
@@ -0,0 +1,84 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITBUF_H
#define GITBUF_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/git_buf_converter.h"
using namespace node;
using namespace v8;
class GitBuf;
struct GitBufTraits {
typedef GitBuf cppClass;
typedef git_buf cType;
static const bool isDuplicable = false;
static void duplicate(git_buf **dest, git_buf *src) {
Nan::ThrowError("duplicate called on GitBuf which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_buf *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_buf_dispose(raw); // :: to avoid calling this free recursively
}
}
};
class GitBuf : public
NodeGitWrapper<GitBufTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitBufTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitBuf()
: NodeGitWrapper<GitBufTraits>(
"A new GitBuf cannot be instantiated."
)
{}
GitBuf(git_buf *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitBufTraits>(raw, selfFreeing, owner)
{}
~GitBuf();
static NAN_METHOD(Ptr);
static NAN_METHOD(Asize);
static NAN_METHOD(Size);
static NAN_METHOD(ContainsNul);
static NAN_METHOD(Dispose);
static NAN_METHOD(Grow);
static NAN_METHOD(IsBinary);
static NAN_METHOD(Set);
};
#endif
+70
View File
@@ -0,0 +1,70 @@
#ifndef CALLBACK_WRAPPER_H
#define CALLBACK_WRAPPER_H
#include <nan.h>
#include <uv.h>
using namespace v8;
using namespace node;
class CallbackWrapper {
Nan::Callback* jsCallback;
// throttling data, used for callbacks that need to be throttled
int throttle; // in milliseconds - if > 0, calls to the JS callback will be throttled
uint64_t lastCallTime;
// false will trigger the callback and not wait for the callback to finish
// in this case, the underlying libgit2 function will immediately be given
// the default result
bool waitForResult;
public:
CallbackWrapper() {
jsCallback = NULL;
lastCallTime = 0;
throttle = 0;
}
~CallbackWrapper() {
SetCallback(NULL);
}
bool HasCallback() {
return jsCallback != NULL;
}
Nan::Callback* GetCallback() {
return jsCallback;
}
void SetCallback(Nan::Callback* callback, int throttle = 0, bool waitForResult = true) {
if(jsCallback) {
delete jsCallback;
}
jsCallback = callback;
this->throttle = throttle;
this->waitForResult = waitForResult;
}
bool ShouldWaitForResult() {
return waitForResult;
}
bool WillBeThrottled() {
if(!throttle) {
return false;
}
// throttle if needed
uint64_t now = uv_hrtime();
if(lastCallTime > 0 && now < lastCallTime + throttle * (uint64_t)1000000) {
// throttled
return true;
} else {
lastCallTime = now;
return false;
}
}
};
#endif
+71
View File
@@ -0,0 +1,71 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCERT_H
#define GITCERT_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitCert;
struct GitCertTraits {
typedef GitCert cppClass;
typedef git_cert cType;
static const bool isDuplicable = false;
static void duplicate(git_cert **dest, git_cert *src) {
Nan::ThrowError("duplicate called on GitCert which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_cert *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCert : public
NodeGitWrapper<GitCertTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCertTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCert()
: NodeGitWrapper<GitCertTraits>(
"A new GitCert cannot be instantiated."
)
{}
GitCert(git_cert *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCertTraits>(raw, selfFreeing, owner)
{}
~GitCert();
static NAN_METHOD(CertType);
};
#endif
+76
View File
@@ -0,0 +1,76 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCERTHOSTKEY_H
#define GITCERTHOSTKEY_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/cert.h"
using namespace node;
using namespace v8;
class GitCertHostkey;
struct GitCertHostkeyTraits {
typedef GitCertHostkey cppClass;
typedef git_cert_hostkey cType;
static const bool isDuplicable = false;
static void duplicate(git_cert_hostkey **dest, git_cert_hostkey *src) {
Nan::ThrowError("duplicate called on GitCertHostkey which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_cert_hostkey *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCertHostkey : public
NodeGitWrapper<GitCertHostkeyTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCertHostkeyTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCertHostkey()
: NodeGitWrapper<GitCertHostkeyTraits>(
"A new GitCertHostkey cannot be instantiated."
)
{}
GitCertHostkey(git_cert_hostkey *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCertHostkeyTraits>(raw, selfFreeing, owner)
{}
~GitCertHostkey();
static NAN_METHOD(Parent);
static NAN_METHOD(Type);
static NAN_METHOD(HashMd5);
static NAN_METHOD(HashSha1);
static NAN_METHOD(HashSha256);
};
#endif
+76
View File
@@ -0,0 +1,76 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCERTX509_H
#define GITCERTX509_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/wrapper.h"
#include "node_buffer.h"
#include "../include/cert.h"
using namespace node;
using namespace v8;
class GitCertX509;
struct GitCertX509Traits {
typedef GitCertX509 cppClass;
typedef git_cert_x509 cType;
static const bool isDuplicable = false;
static void duplicate(git_cert_x509 **dest, git_cert_x509 *src) {
Nan::ThrowError("duplicate called on GitCertX509 which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_cert_x509 *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCertX509 : public
NodeGitWrapper<GitCertX509Traits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCertX509Traits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCertX509()
: NodeGitWrapper<GitCertX509Traits>(
"A new GitCertX509 cannot be instantiated."
)
{}
GitCertX509(git_cert_x509 *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCertX509Traits>(raw, selfFreeing, owner)
{}
~GitCertX509();
static NAN_METHOD(Parent);
static NAN_METHOD(Data);
static NAN_METHOD(Len);
};
#endif
+114
View File
@@ -0,0 +1,114 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCHECKOUT_H
#define GITCHECKOUT_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/checkout_options.h"
#include "../include/index.h"
#include "../include/object.h"
using namespace node;
using namespace v8;
class GitCheckout : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
struct HeadBaton {
int error_code;
const git_error* error;
git_repository * repo;
const git_checkout_options * opts;
};
class HeadWorker : public Nan::AsyncWorker {
public:
HeadWorker(
HeadBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~HeadWorker() {};
void Execute();
void HandleOKCallback();
private:
HeadBaton *baton;
};
static NAN_METHOD(Head);
struct IndexBaton {
int error_code;
const git_error* error;
git_repository * repo;
git_index * index;
const git_checkout_options * opts;
};
class IndexWorker : public Nan::AsyncWorker {
public:
IndexWorker(
IndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~IndexWorker() {};
void Execute();
void HandleOKCallback();
private:
IndexBaton *baton;
};
static NAN_METHOD(Index);
struct TreeBaton {
int error_code;
const git_error* error;
git_repository * repo;
const git_object * treeish;
const git_checkout_options * opts;
};
class TreeWorker : public Nan::AsyncWorker {
public:
TreeWorker(
TreeBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeBaton *baton;
};
static NAN_METHOD(Tree);
};
#endif
+226
View File
@@ -0,0 +1,226 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITCHECKOUTOPTIONS_H
#define GITCHECKOUTOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/diff_file.h"
#include "../include/strarray.h"
#include "../include/tree.h"
#include "../include/index.h"
#include "../include/checkout_perfdata.h"
using namespace node;
using namespace v8;
class GitCheckoutOptions;
struct GitCheckoutOptionsTraits {
typedef GitCheckoutOptions cppClass;
typedef git_checkout_options cType;
static const bool isDuplicable = false;
static void duplicate(git_checkout_options **dest, git_checkout_options *src) {
Nan::ThrowError("duplicate called on GitCheckoutOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_checkout_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCheckoutOptions : public NodeGitWrapper<GitCheckoutOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitCheckoutOptionsTraits>;
public:
GitCheckoutOptions(git_checkout_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
static int notify_cb_cppCallback (
git_checkout_notify_t why
,
const char * path
,
const git_diff_file * baseline
,
const git_diff_file * target
,
const git_diff_file * workdir
,
void * payload
);
static void notify_cb_async(void *baton);
static void notify_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct NotifyCbBaton : public AsyncBatonWithResult<int> {
git_checkout_notify_t why;
const char * path;
const git_diff_file * baseline;
const git_diff_file * target;
const git_diff_file * workdir;
void * payload;
NotifyCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitCheckoutOptions * notify_cb_getInstanceFromBaton (
NotifyCbBaton *baton);
static int progress_cb_cppCallback (
const char * path
,
size_t completed_steps
,
size_t total_steps
,
void * payload
);
static void progress_cb_async(void *baton);
static void progress_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct ProgressCbBaton : public AsyncBatonWithResult<int> {
const char * path;
size_t completed_steps;
size_t total_steps;
void * payload;
ProgressCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitCheckoutOptions * progress_cb_getInstanceFromBaton (
ProgressCbBaton *baton);
static int perfdata_cb_cppCallback (
const git_checkout_perfdata * perfdata
,
void * payload
);
static void perfdata_cb_async(void *baton);
static void perfdata_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct PerfdataCbBaton : public AsyncBatonWithResult<int> {
const git_checkout_perfdata * perfdata;
void * payload;
PerfdataCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitCheckoutOptions * perfdata_cb_getInstanceFromBaton (
PerfdataCbBaton *baton);
private:
GitCheckoutOptions();
~GitCheckoutOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetCheckoutStrategy);
static NAN_SETTER(SetCheckoutStrategy);
static NAN_GETTER(GetDisableFilters);
static NAN_SETTER(SetDisableFilters);
static NAN_GETTER(GetDirMode);
static NAN_SETTER(SetDirMode);
static NAN_GETTER(GetFileMode);
static NAN_SETTER(SetFileMode);
static NAN_GETTER(GetFileOpenFlags);
static NAN_SETTER(SetFileOpenFlags);
static NAN_GETTER(GetNotifyFlags);
static NAN_SETTER(SetNotifyFlags);
CallbackWrapper notify_cb;
static NAN_GETTER(GetNotifyCb);
static NAN_SETTER(SetNotifyCb);
Nan::Persistent<Value> notify_payload;
static NAN_GETTER(GetNotifyPayload);
static NAN_SETTER(SetNotifyPayload);
CallbackWrapper progress_cb;
static NAN_GETTER(GetProgressCb);
static NAN_SETTER(SetProgressCb);
Nan::Persistent<Value> progress_payload;
static NAN_GETTER(GetProgressPayload);
static NAN_SETTER(SetProgressPayload);
Nan::Persistent<Object> paths;
static NAN_GETTER(GetPaths);
static NAN_SETTER(SetPaths);
Nan::Persistent<Object> baseline;
static NAN_GETTER(GetBaseline);
static NAN_SETTER(SetBaseline);
Nan::Persistent<Object> baseline_index;
static NAN_GETTER(GetBaselineIndex);
static NAN_SETTER(SetBaselineIndex);
static NAN_GETTER(GetTargetDirectory);
static NAN_SETTER(SetTargetDirectory);
static NAN_GETTER(GetAncestorLabel);
static NAN_SETTER(SetAncestorLabel);
static NAN_GETTER(GetOurLabel);
static NAN_SETTER(SetOurLabel);
static NAN_GETTER(GetTheirLabel);
static NAN_SETTER(SetTheirLabel);
CallbackWrapper perfdata_cb;
static NAN_GETTER(GetPerfdataCb);
static NAN_SETTER(SetPerfdataCb);
Nan::Persistent<Value> perfdata_payload;
static NAN_GETTER(GetPerfdataPayload);
static NAN_SETTER(SetPerfdataPayload);
};
#endif
+73
View File
@@ -0,0 +1,73 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCHECKOUTPERFDATA_H
#define GITCHECKOUTPERFDATA_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitCheckoutPerfdata;
struct GitCheckoutPerfdataTraits {
typedef GitCheckoutPerfdata cppClass;
typedef git_checkout_perfdata cType;
static const bool isDuplicable = false;
static void duplicate(git_checkout_perfdata **dest, git_checkout_perfdata *src) {
Nan::ThrowError("duplicate called on GitCheckoutPerfdata which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_checkout_perfdata *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCheckoutPerfdata : public
NodeGitWrapper<GitCheckoutPerfdataTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCheckoutPerfdataTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCheckoutPerfdata()
: NodeGitWrapper<GitCheckoutPerfdataTraits>(
"A new GitCheckoutPerfdata cannot be instantiated."
)
{}
GitCheckoutPerfdata(git_checkout_perfdata *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCheckoutPerfdataTraits>(raw, selfFreeing, owner)
{}
~GitCheckoutPerfdata();
static NAN_METHOD(MkdirCalls);
static NAN_METHOD(StatCalls);
static NAN_METHOD(ChmodCalls);
};
#endif
+95
View File
@@ -0,0 +1,95 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCHERRYPICK_H
#define GITCHERRYPICK_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/commit.h"
#include "../include/cherrypick_options.h"
#include "../include/index.h"
#include "../include/merge_options.h"
using namespace node;
using namespace v8;
class GitCherrypick : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
struct CherrypickBaton {
int error_code;
const git_error* error;
git_repository * repo;
git_commit * commit;
const git_cherrypick_options * cherrypick_options;
};
class CherrypickWorker : public Nan::AsyncWorker {
public:
CherrypickWorker(
CherrypickBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CherrypickWorker() {};
void Execute();
void HandleOKCallback();
private:
CherrypickBaton *baton;
};
static NAN_METHOD(Cherrypick);
struct CommitBaton {
int error_code;
const git_error* error;
git_index * out;
git_repository * repo;
git_commit * cherrypick_commit;
git_commit * our_commit;
unsigned int mainline;
const git_merge_options * merge_options;
};
class CommitWorker : public Nan::AsyncWorker {
public:
CommitWorker(
CommitBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CommitWorker() {};
void Execute();
void HandleOKCallback();
private:
CommitBaton *baton;
};
static NAN_METHOD(Commit);
};
#endif
+80
View File
@@ -0,0 +1,80 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITCHERRYPICKOPTIONS_H
#define GITCHERRYPICKOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/merge_options.h"
#include "../include/checkout_options.h"
using namespace node;
using namespace v8;
class GitCherrypickOptions;
struct GitCherrypickOptionsTraits {
typedef GitCherrypickOptions cppClass;
typedef git_cherrypick_options cType;
static const bool isDuplicable = false;
static void duplicate(git_cherrypick_options **dest, git_cherrypick_options *src) {
Nan::ThrowError("duplicate called on GitCherrypickOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_cherrypick_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCherrypickOptions : public NodeGitWrapper<GitCherrypickOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitCherrypickOptionsTraits>;
public:
GitCherrypickOptions(git_cherrypick_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCherrypickOptions();
~GitCherrypickOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetMainline);
static NAN_SETTER(SetMainline);
Nan::Persistent<Object> merge_opts;
static NAN_GETTER(GetMergeOpts);
static NAN_SETTER(SetMergeOpts);
Nan::Persistent<Object> checkout_opts;
static NAN_GETTER(GetCheckoutOpts);
static NAN_SETTER(SetCheckoutOpts);
};
#endif
+66
View File
@@ -0,0 +1,66 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCLONE_H
#define GITCLONE_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/repository.h"
#include "../include/clone_options.h"
using namespace node;
using namespace v8;
class GitClone : public
Nan::ObjectWrap
{
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
struct CloneBaton {
int error_code;
const git_error* error;
git_repository * out;
const char * url;
const char * local_path;
const git_clone_options * options;
};
class CloneWorker : public Nan::AsyncWorker {
public:
CloneWorker(
CloneBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CloneWorker() {};
void Execute();
void HandleOKCallback();
private:
CloneBaton *baton;
};
static NAN_METHOD(Clone);
};
#endif
+98
View File
@@ -0,0 +1,98 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITCLONEOPTIONS_H
#define GITCLONEOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/checkout_options.h"
#include "../include/fetch_options.h"
using namespace node;
using namespace v8;
class GitCloneOptions;
struct GitCloneOptionsTraits {
typedef GitCloneOptions cppClass;
typedef git_clone_options cType;
static const bool isDuplicable = false;
static void duplicate(git_clone_options **dest, git_clone_options *src) {
Nan::ThrowError("duplicate called on GitCloneOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_clone_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCloneOptions : public NodeGitWrapper<GitCloneOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitCloneOptionsTraits>;
public:
GitCloneOptions(git_clone_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCloneOptions();
~GitCloneOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
Nan::Persistent<Object> checkout_opts;
static NAN_GETTER(GetCheckoutOpts);
static NAN_SETTER(SetCheckoutOpts);
Nan::Persistent<Object> fetch_opts;
static NAN_GETTER(GetFetchOpts);
static NAN_SETTER(SetFetchOpts);
static NAN_GETTER(GetBare);
static NAN_SETTER(SetBare);
static NAN_GETTER(GetLocal);
static NAN_SETTER(SetLocal);
static NAN_GETTER(GetCheckoutBranch);
static NAN_SETTER(SetCheckoutBranch);
Nan::Persistent<Value> repository_cb_payload;
static NAN_GETTER(GetRepositoryCbPayload);
static NAN_SETTER(SetRepositoryCbPayload);
Nan::Persistent<Value> remote_cb_payload;
static NAN_GETTER(GetRemoteCbPayload);
static NAN_SETTER(SetRemoteCbPayload);
};
#endif
+450
View File
@@ -0,0 +1,450 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCOMMIT_H
#define GITCOMMIT_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/oid.h"
#include "../include/signature.h"
#include "../include/tree.h"
#include "../include/mailmap.h"
#include "../include/repository.h"
#include "../include/buf.h"
// Forward declaration.
struct git_commit {
};
using namespace node;
using namespace v8;
class GitCommit;
struct GitCommitTraits {
typedef GitCommit cppClass;
typedef git_commit cType;
static const bool isDuplicable = false;
static void duplicate(git_commit **dest, git_commit *src) {
Nan::ThrowError("duplicate called on GitCommit which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_commit *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_commit_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCommit : public
NodeGitWrapper<GitCommitTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCommitTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCommit()
: NodeGitWrapper<GitCommitTraits>(
"A new GitCommit cannot be instantiated."
)
{}
GitCommit(git_commit *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCommitTraits>(raw, selfFreeing, owner)
{}
~GitCommit();
struct AmendBaton {
int error_code;
const git_error* error;
git_oid * id;
const git_commit * commit_to_amend;
const char * update_ref;
const git_signature * author;
const git_signature * committer;
const char * message_encoding;
const char * message;
const git_tree * tree;
};
class AmendWorker : public Nan::AsyncWorker {
public:
AmendWorker(
AmendBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~AmendWorker() {};
void Execute();
void HandleOKCallback();
private:
AmendBaton *baton;
};
static NAN_METHOD(Amend);
static NAN_METHOD(Author);
struct AuthorWithMailmapBaton {
int error_code;
const git_error* error;
git_signature * out;
const git_commit * commit;
const git_mailmap * mailmap;
};
class AuthorWithMailmapWorker : public Nan::AsyncWorker {
public:
AuthorWithMailmapWorker(
AuthorWithMailmapBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~AuthorWithMailmapWorker() {};
void Execute();
void HandleOKCallback();
private:
AuthorWithMailmapBaton *baton;
};
static NAN_METHOD(AuthorWithMailmap);
static NAN_METHOD(Body);
static NAN_METHOD(Committer);
struct CommitterWithMailmapBaton {
int error_code;
const git_error* error;
git_signature * out;
const git_commit * commit;
const git_mailmap * mailmap;
};
class CommitterWithMailmapWorker : public Nan::AsyncWorker {
public:
CommitterWithMailmapWorker(
CommitterWithMailmapBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CommitterWithMailmapWorker() {};
void Execute();
void HandleOKCallback();
private:
CommitterWithMailmapBaton *baton;
};
static NAN_METHOD(CommitterWithMailmap);
struct CreateBaton {
int error_code;
const git_error* error;
git_oid * id;
git_repository * repo;
const char * update_ref;
const git_signature * author;
const git_signature * committer;
const char * message_encoding;
const char * message;
const git_tree * tree;
size_t parent_count;
const git_commit ** parents;
};
class CreateWorker : public Nan::AsyncWorker {
public:
CreateWorker(
CreateBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateBaton *baton;
};
static NAN_METHOD(Create);
struct CreateBufferBaton {
int error_code;
const git_error* error;
git_buf * out;
git_repository * repo;
const git_signature * author;
const git_signature * committer;
const char * message_encoding;
const char * message;
const git_tree * tree;
size_t parent_count;
const git_commit ** parents;
};
class CreateBufferWorker : public Nan::AsyncWorker {
public:
CreateBufferWorker(
CreateBufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateBufferWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateBufferBaton *baton;
};
static NAN_METHOD(CreateBuffer);
static NAN_METHOD(CreateV);
struct CreateWithSignatureBaton {
int error_code;
const git_error* error;
git_oid * out;
git_repository * repo;
const char * commit_content;
const char * signature;
const char * signature_field;
};
class CreateWithSignatureWorker : public Nan::AsyncWorker {
public:
CreateWithSignatureWorker(
CreateWithSignatureBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateWithSignatureWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateWithSignatureBaton *baton;
};
static NAN_METHOD(CreateWithSignature);
struct DupBaton {
int error_code;
const git_error* error;
git_commit * out;
git_commit * source;
};
class DupWorker : public Nan::AsyncWorker {
public:
DupWorker(
DupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~DupWorker() {};
void Execute();
void HandleOKCallback();
private:
DupBaton *baton;
};
static NAN_METHOD(Dup);
struct ExtractSignatureBaton {
int error_code;
const git_error* error;
git_buf signature;
git_buf signed_data;
git_repository * repo;
git_oid * commit_id;
bool commit_idNeedsFree;
char * field;
};
class ExtractSignatureWorker : public Nan::AsyncWorker {
public:
ExtractSignatureWorker(
ExtractSignatureBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~ExtractSignatureWorker() {};
void Execute();
void HandleOKCallback();
private:
ExtractSignatureBaton *baton;
};
static NAN_METHOD(ExtractSignature);
struct HeaderFieldBaton {
int error_code;
const git_error* error;
git_buf * out;
const git_commit * commit;
const char * field;
};
class HeaderFieldWorker : public Nan::AsyncWorker {
public:
HeaderFieldWorker(
HeaderFieldBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~HeaderFieldWorker() {};
void Execute();
void HandleOKCallback();
private:
HeaderFieldBaton *baton;
};
static NAN_METHOD(HeaderField);
static NAN_METHOD(Id);
struct LookupBaton {
int error_code;
const git_error* error;
git_commit * commit;
git_repository * repo;
const git_oid * id;
bool idNeedsFree;
};
class LookupWorker : public Nan::AsyncWorker {
public:
LookupWorker(
LookupBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupBaton *baton;
};
static NAN_METHOD(Lookup);
struct LookupPrefixBaton {
int error_code;
const git_error* error;
git_commit * commit;
git_repository * repo;
const git_oid * id;
bool idNeedsFree;
size_t len;
};
class LookupPrefixWorker : public Nan::AsyncWorker {
public:
LookupPrefixWorker(
LookupPrefixBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LookupPrefixWorker() {};
void Execute();
void HandleOKCallback();
private:
LookupPrefixBaton *baton;
};
static NAN_METHOD(LookupPrefix);
static NAN_METHOD(Message);
static NAN_METHOD(MessageEncoding);
static NAN_METHOD(MessageRaw);
struct NthGenAncestorBaton {
int error_code;
const git_error* error;
git_commit * ancestor;
const git_commit * commit;
unsigned int n;
};
class NthGenAncestorWorker : public Nan::AsyncWorker {
public:
NthGenAncestorWorker(
NthGenAncestorBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~NthGenAncestorWorker() {};
void Execute();
void HandleOKCallback();
private:
NthGenAncestorBaton *baton;
};
static NAN_METHOD(NthGenAncestor);
static NAN_METHOD(Owner);
struct ParentBaton {
int error_code;
const git_error* error;
git_commit * out;
const git_commit * commit;
unsigned int n;
};
class ParentWorker : public Nan::AsyncWorker {
public:
ParentWorker(
ParentBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~ParentWorker() {};
void Execute();
void HandleOKCallback();
private:
ParentBaton *baton;
};
static NAN_METHOD(Parent);
static NAN_METHOD(ParentId);
static NAN_METHOD(Parentcount);
static NAN_METHOD(RawHeader);
static NAN_METHOD(Summary);
static NAN_METHOD(Time);
static NAN_METHOD(TimeOffset);
static NAN_METHOD(Tree);
static NAN_METHOD(TreeId);
};
#endif
+525
View File
@@ -0,0 +1,525 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCONFIG_H
#define GITCONFIG_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/git_buf_converter.h"
#include "../include/buf.h"
#include "../include/config_entry.h"
#include "../include/transaction.h"
// Forward declaration.
struct git_config {
};
using namespace node;
using namespace v8;
class GitConfig;
struct GitConfigTraits {
typedef GitConfig cppClass;
typedef git_config cType;
static const bool isDuplicable = false;
static void duplicate(git_config **dest, git_config *src) {
Nan::ThrowError("duplicate called on GitConfig which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_config *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_config_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitConfig : public
NodeGitWrapper<GitConfigTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitConfigTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitConfig()
: NodeGitWrapper<GitConfigTraits>(
"A new GitConfig cannot be instantiated."
)
{}
GitConfig(git_config *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitConfigTraits>(raw, selfFreeing, owner)
{}
~GitConfig();
static NAN_METHOD(DeleteEntry);
static NAN_METHOD(DeleteMultivar);
struct FindGlobalBaton {
int error_code;
const git_error* error;
git_buf * out;
};
class FindGlobalWorker : public Nan::AsyncWorker {
public:
FindGlobalWorker(
FindGlobalBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindGlobalWorker() {};
void Execute();
void HandleOKCallback();
private:
FindGlobalBaton *baton;
};
static NAN_METHOD(FindGlobal);
struct FindProgramdataBaton {
int error_code;
const git_error* error;
git_buf * out;
};
class FindProgramdataWorker : public Nan::AsyncWorker {
public:
FindProgramdataWorker(
FindProgramdataBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindProgramdataWorker() {};
void Execute();
void HandleOKCallback();
private:
FindProgramdataBaton *baton;
};
static NAN_METHOD(FindProgramdata);
struct FindSystemBaton {
int error_code;
const git_error* error;
git_buf * out;
};
class FindSystemWorker : public Nan::AsyncWorker {
public:
FindSystemWorker(
FindSystemBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindSystemWorker() {};
void Execute();
void HandleOKCallback();
private:
FindSystemBaton *baton;
};
static NAN_METHOD(FindSystem);
struct FindXdgBaton {
int error_code;
const git_error* error;
git_buf * out;
};
class FindXdgWorker : public Nan::AsyncWorker {
public:
FindXdgWorker(
FindXdgBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindXdgWorker() {};
void Execute();
void HandleOKCallback();
private:
FindXdgBaton *baton;
};
static NAN_METHOD(FindXdg);
struct GetBoolBaton {
int error_code;
const git_error* error;
int * out;
const git_config * cfg;
const char * name;
};
class GetBoolWorker : public Nan::AsyncWorker {
public:
GetBoolWorker(
GetBoolBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetBoolWorker() {};
void Execute();
void HandleOKCallback();
private:
GetBoolBaton *baton;
};
static NAN_METHOD(GetBool);
struct GetEntryBaton {
int error_code;
const git_error* error;
git_config_entry * out;
const git_config * cfg;
const char * name;
};
class GetEntryWorker : public Nan::AsyncWorker {
public:
GetEntryWorker(
GetEntryBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetEntryWorker() {};
void Execute();
void HandleOKCallback();
private:
GetEntryBaton *baton;
};
static NAN_METHOD(GetEntry);
struct GetInt32Baton {
int error_code;
const git_error* error;
int32_t * out;
const git_config * cfg;
const char * name;
};
class GetInt32Worker : public Nan::AsyncWorker {
public:
GetInt32Worker(
GetInt32Baton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetInt32Worker() {};
void Execute();
void HandleOKCallback();
private:
GetInt32Baton *baton;
};
static NAN_METHOD(GetInt32);
struct GetInt64Baton {
int error_code;
const git_error* error;
int64_t * out;
const git_config * cfg;
const char * name;
};
class GetInt64Worker : public Nan::AsyncWorker {
public:
GetInt64Worker(
GetInt64Baton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetInt64Worker() {};
void Execute();
void HandleOKCallback();
private:
GetInt64Baton *baton;
};
static NAN_METHOD(GetInt64);
struct GetPathBaton {
int error_code;
const git_error* error;
git_buf * out;
const git_config * cfg;
const char * name;
};
class GetPathWorker : public Nan::AsyncWorker {
public:
GetPathWorker(
GetPathBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetPathWorker() {};
void Execute();
void HandleOKCallback();
private:
GetPathBaton *baton;
};
static NAN_METHOD(GetPath);
struct GetStringBufBaton {
int error_code;
const git_error* error;
git_buf * out;
const git_config * cfg;
const char * name;
};
class GetStringBufWorker : public Nan::AsyncWorker {
public:
GetStringBufWorker(
GetStringBufBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetStringBufWorker() {};
void Execute();
void HandleOKCallback();
private:
GetStringBufBaton *baton;
};
static NAN_METHOD(GetStringBuf);
struct LockBaton {
int error_code;
const git_error* error;
git_transaction * tx;
git_config * cfg;
};
class LockWorker : public Nan::AsyncWorker {
public:
LockWorker(
LockBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LockWorker() {};
void Execute();
void HandleOKCallback();
private:
LockBaton *baton;
};
static NAN_METHOD(Lock);
struct OpenDefaultBaton {
int error_code;
const git_error* error;
git_config * out;
};
class OpenDefaultWorker : public Nan::AsyncWorker {
public:
OpenDefaultWorker(
OpenDefaultBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~OpenDefaultWorker() {};
void Execute();
void HandleOKCallback();
private:
OpenDefaultBaton *baton;
};
static NAN_METHOD(OpenDefault);
struct OpenOndiskBaton {
int error_code;
const git_error* error;
git_config * out;
const char * path;
};
class OpenOndiskWorker : public Nan::AsyncWorker {
public:
OpenOndiskWorker(
OpenOndiskBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~OpenOndiskWorker() {};
void Execute();
void HandleOKCallback();
private:
OpenOndiskBaton *baton;
};
static NAN_METHOD(OpenOndisk);
struct SetBoolBaton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
int value;
};
class SetBoolWorker : public Nan::AsyncWorker {
public:
SetBoolWorker(
SetBoolBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetBoolWorker() {};
void Execute();
void HandleOKCallback();
private:
SetBoolBaton *baton;
};
static NAN_METHOD(SetBool);
struct SetInt32Baton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
int32_t value;
};
class SetInt32Worker : public Nan::AsyncWorker {
public:
SetInt32Worker(
SetInt32Baton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetInt32Worker() {};
void Execute();
void HandleOKCallback();
private:
SetInt32Baton *baton;
};
static NAN_METHOD(SetInt32);
struct SetInt64Baton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
int64_t value;
};
class SetInt64Worker : public Nan::AsyncWorker {
public:
SetInt64Worker(
SetInt64Baton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetInt64Worker() {};
void Execute();
void HandleOKCallback();
private:
SetInt64Baton *baton;
};
static NAN_METHOD(SetInt64);
struct SetMultivarBaton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
const char * regexp;
const char * value;
};
class SetMultivarWorker : public Nan::AsyncWorker {
public:
SetMultivarWorker(
SetMultivarBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetMultivarWorker() {};
void Execute();
void HandleOKCallback();
private:
SetMultivarBaton *baton;
};
static NAN_METHOD(SetMultivar);
struct SetStringBaton {
int error_code;
const git_error* error;
git_config * cfg;
const char * name;
const char * value;
};
class SetStringWorker : public Nan::AsyncWorker {
public:
SetStringWorker(
SetStringBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SetStringWorker() {};
void Execute();
void HandleOKCallback();
private:
SetStringBaton *baton;
};
static NAN_METHOD(SetString);
struct SnapshotBaton {
int error_code;
const git_error* error;
git_config * out;
git_config * config;
};
class SnapshotWorker : public Nan::AsyncWorker {
public:
SnapshotWorker(
SnapshotBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SnapshotWorker() {};
void Execute();
void HandleOKCallback();
private:
SnapshotBaton *baton;
};
static NAN_METHOD(Snapshot);
};
#endif
+70
View File
@@ -0,0 +1,70 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCONFIGENTRY_H
#define GITCONFIGENTRY_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitConfigEntry;
struct GitConfigEntryTraits {
typedef GitConfigEntry cppClass;
typedef git_config_entry cType;
static const bool isDuplicable = false;
static void duplicate(git_config_entry **dest, git_config_entry *src) {
Nan::ThrowError("duplicate called on GitConfigEntry which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = false;
static void free(git_config_entry *raw) {
Nan::ThrowError("free called on GitConfigEntry which cannot be freed");
}
};
class GitConfigEntry : public
NodeGitWrapper<GitConfigEntryTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitConfigEntryTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitConfigEntry()
: NodeGitWrapper<GitConfigEntryTraits>(
"A new GitConfigEntry cannot be instantiated."
)
{}
GitConfigEntry(git_config_entry *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitConfigEntryTraits>(raw, selfFreeing, owner)
{}
~GitConfigEntry();
static NAN_METHOD(Name);
static NAN_METHOD(Value);
static NAN_METHOD(Level);
};
#endif
+149
View File
@@ -0,0 +1,149 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCONFIGITERATOR_H
#define GITCONFIGITERATOR_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/config.h"
#include "../include/config_entry.h"
// Forward declaration.
struct git_config_iterator {
};
using namespace node;
using namespace v8;
class GitConfigIterator;
struct GitConfigIteratorTraits {
typedef GitConfigIterator cppClass;
typedef git_config_iterator cType;
static const bool isDuplicable = false;
static void duplicate(git_config_iterator **dest, git_config_iterator *src) {
Nan::ThrowError("duplicate called on GitConfigIterator which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_config_iterator *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_config_iterator_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitConfigIterator : public
NodeGitWrapper<GitConfigIteratorTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitConfigIteratorTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitConfigIterator()
: NodeGitWrapper<GitConfigIteratorTraits>(
"A new GitConfigIterator cannot be instantiated."
)
{}
GitConfigIterator(git_config_iterator *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitConfigIteratorTraits>(raw, selfFreeing, owner)
{}
~GitConfigIterator();
struct CreateBaton {
int error_code;
const git_error* error;
git_config_iterator * out;
const git_config * cfg;
};
class CreateWorker : public Nan::AsyncWorker {
public:
CreateWorker(
CreateBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~CreateWorker() {};
void Execute();
void HandleOKCallback();
private:
CreateBaton *baton;
};
static NAN_METHOD(Create);
struct GlobNewBaton {
int error_code;
const git_error* error;
git_config_iterator * out;
const git_config * cfg;
const char * regexp;
};
class GlobNewWorker : public Nan::AsyncWorker {
public:
GlobNewWorker(
GlobNewBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GlobNewWorker() {};
void Execute();
void HandleOKCallback();
private:
GlobNewBaton *baton;
};
static NAN_METHOD(GlobNew);
struct GitConfigMultivarIteratorNewBaton {
int error_code;
const git_error* error;
git_config_iterator * out;
const git_config * cfg;
const char * name;
const char * regexp;
};
class GitConfigMultivarIteratorNewWorker : public Nan::AsyncWorker {
public:
GitConfigMultivarIteratorNewWorker(
GitConfigMultivarIteratorNewBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GitConfigMultivarIteratorNewWorker() {};
void Execute();
void HandleOKCallback();
private:
GitConfigMultivarIteratorNewBaton *baton;
};
static NAN_METHOD(GitConfigMultivarIteratorNew);
static NAN_METHOD(GitConfigNext);
};
#endif
+73
View File
@@ -0,0 +1,73 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCONFIGMAP_H
#define GITCONFIGMAP_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitConfigmap;
struct GitConfigmapTraits {
typedef GitConfigmap cppClass;
typedef git_configmap cType;
static const bool isDuplicable = false;
static void duplicate(git_configmap **dest, git_configmap *src) {
Nan::ThrowError("duplicate called on GitConfigmap which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_configmap *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitConfigmap : public
NodeGitWrapper<GitConfigmapTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitConfigmapTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitConfigmap()
: NodeGitWrapper<GitConfigmapTraits>(
"A new GitConfigmap cannot be instantiated."
)
{}
GitConfigmap(git_configmap *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitConfigmapTraits>(raw, selfFreeing, owner)
{}
~GitConfigmap();
static NAN_METHOD(Type);
static NAN_METHOD(StrMatch);
static NAN_METHOD(MapValue);
};
#endif
+75
View File
@@ -0,0 +1,75 @@
#ifndef CONVENIENTHUNK_H
#define CONVENIENTHUNK_H
// generated from class_header.h
#include <nan.h>
#include <string>
#include "async_baton.h"
#include "promise_completion.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
struct HunkData {
git_diff_hunk hunk;
std::vector<git_diff_line *> *lines;
size_t numLines;
};
void HunkDataFree(HunkData *hunk);
using namespace node;
using namespace v8;
class ConvenientHunk : public Nan::ObjectWrap {
public:
static Nan::Persistent<Function> constructor_template;
static void InitializeComponent (v8::Local<v8::Object> target);
static v8::Local<v8::Value> New(void *raw);
HunkData *GetValue();
char *GetHeader();
size_t GetSize();
private:
ConvenientHunk(HunkData *hunk);
~ConvenientHunk();
HunkData *hunk;
static NAN_METHOD(JSNewFunction);
static NAN_METHOD(Size);
static NAN_METHOD(OldStart);
static NAN_METHOD(OldLines);
static NAN_METHOD(NewStart);
static NAN_METHOD(NewLines);
static NAN_METHOD(HeaderLen);
static NAN_METHOD(Header);
struct LinesBaton {
HunkData *hunk;
std::vector<git_diff_line *> *lines;
};
class LinesWorker : public Nan::AsyncWorker {
public:
LinesWorker(
LinesBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~LinesWorker() {};
void Execute();
void HandleOKCallback();
private:
LinesBaton *baton;
};
static NAN_METHOD(Lines);
};
#endif
+108
View File
@@ -0,0 +1,108 @@
#ifndef CONVENIENTPATCH_H
#define CONVENIENTPATCH_H
// generated from class_header.h
#include <nan.h>
#include <string>
#include "async_baton.h"
#include "promise_completion.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/convenient_hunk.h"
struct ConvenientLineStats {
size_t context;
size_t additions;
size_t deletions;
};
struct PatchData {
ConvenientLineStats lineStats;
git_delta_t status;
git_diff_file new_file;
git_diff_file old_file;
std::vector<HunkData *> *hunks;
size_t numHunks;
};
PatchData *createFromRaw(git_patch *raw);
void PatchDataFree(PatchData *patch);
using namespace node;
using namespace v8;
class ConvenientPatch : public Nan::ObjectWrap {
public:
static Nan::Persistent<Function> constructor_template;
static void InitializeComponent (v8::Local<v8::Object> target);
static v8::Local<v8::Value> New(void *raw);
ConvenientLineStats GetLineStats();
git_delta_t GetStatus();
git_diff_file GetOldFile();
git_diff_file GetNewFile();
size_t GetNumHunks();
PatchData *GetValue();
private:
ConvenientPatch(PatchData *raw);
~ConvenientPatch();
PatchData *patch;
static NAN_METHOD(JSNewFunction);
// patch methods
static NAN_METHOD(LineStats);
// hunk methods
static NAN_METHOD(Size);
struct HunksBaton {
PatchData *patch;
std::vector<HunkData *> *hunks;
};
class HunksWorker : public Nan::AsyncWorker {
public:
HunksWorker(
HunksBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~HunksWorker() {};
void Execute();
void HandleOKCallback();
private:
HunksBaton *baton;
};
static NAN_METHOD(Hunks);
// delta methods
static NAN_METHOD(OldFile);
static NAN_METHOD(NewFile);
// convenient status methods
static NAN_METHOD(Status);
static NAN_METHOD(IsUnmodified);
static NAN_METHOD(IsAdded);
static NAN_METHOD(IsDeleted);
static NAN_METHOD(IsModified);
static NAN_METHOD(IsRenamed);
static NAN_METHOD(IsCopied);
static NAN_METHOD(IsIgnored);
static NAN_METHOD(IsUntracked);
static NAN_METHOD(IsTypeChange);
static NAN_METHOD(IsUnreadable);
static NAN_METHOD(IsConflicted);
// Hunk methods
};
#endif
+131
View File
@@ -0,0 +1,131 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITCRED_H
#define GITCRED_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitCred;
struct GitCredTraits {
typedef GitCred cppClass;
typedef git_cred cType;
static const bool isDuplicable = false;
static void duplicate(git_cred **dest, git_cred *src) {
Nan::ThrowError("duplicate called on GitCred which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_cred *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_cred_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitCred : public
NodeGitWrapper<GitCredTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitCredTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitCred()
: NodeGitWrapper<GitCredTraits>(
"A new GitCred cannot be instantiated."
)
{}
GitCred(git_cred *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitCredTraits>(raw, selfFreeing, owner)
{}
~GitCred();
static NAN_METHOD(DefaultNew);
static NAN_METHOD(GetUsername);
static NAN_METHOD(HasUsername);
static NAN_METHOD(SshKeyFromAgent);
struct SshKeyMemoryNewBaton {
int error_code;
const git_error* error;
git_cred * out;
const char * username;
const char * publickey;
const char * privatekey;
const char * passphrase;
};
class SshKeyMemoryNewWorker : public Nan::AsyncWorker {
public:
SshKeyMemoryNewWorker(
SshKeyMemoryNewBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~SshKeyMemoryNewWorker() {};
void Execute();
void HandleOKCallback();
private:
SshKeyMemoryNewBaton *baton;
};
static NAN_METHOD(SshKeyMemoryNew);
static NAN_METHOD(SshKeyNew);
struct UsernameNewBaton {
int error_code;
const git_error* error;
git_cred * cred;
const char * username;
};
class UsernameNewWorker : public Nan::AsyncWorker {
public:
UsernameNewWorker(
UsernameNewBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~UsernameNewWorker() {};
void Execute();
void HandleOKCallback();
private:
UsernameNewBaton *baton;
};
static NAN_METHOD(UsernameNew);
static NAN_METHOD(UserpassPlaintextNew);
};
#endif
+76
View File
@@ -0,0 +1,76 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITDESCRIBEFORMATOPTIONS_H
#define GITDESCRIBEFORMATOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
using namespace node;
using namespace v8;
class GitDescribeFormatOptions;
struct GitDescribeFormatOptionsTraits {
typedef GitDescribeFormatOptions cppClass;
typedef git_describe_format_options cType;
static const bool isDuplicable = false;
static void duplicate(git_describe_format_options **dest, git_describe_format_options *src) {
Nan::ThrowError("duplicate called on GitDescribeFormatOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_describe_format_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDescribeFormatOptions : public NodeGitWrapper<GitDescribeFormatOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitDescribeFormatOptionsTraits>;
public:
GitDescribeFormatOptions(git_describe_format_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDescribeFormatOptions();
~GitDescribeFormatOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetAbbreviatedSize);
static NAN_SETTER(SetAbbreviatedSize);
static NAN_GETTER(GetAlwaysUseLongFormat);
static NAN_SETTER(SetAlwaysUseLongFormat);
static NAN_GETTER(GetDirtySuffix);
static NAN_SETTER(SetDirtySuffix);
};
#endif
+84
View File
@@ -0,0 +1,84 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITDESCRIBEOPTIONS_H
#define GITDESCRIBEOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
using namespace node;
using namespace v8;
class GitDescribeOptions;
struct GitDescribeOptionsTraits {
typedef GitDescribeOptions cppClass;
typedef git_describe_options cType;
static const bool isDuplicable = false;
static void duplicate(git_describe_options **dest, git_describe_options *src) {
Nan::ThrowError("duplicate called on GitDescribeOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_describe_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDescribeOptions : public NodeGitWrapper<GitDescribeOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitDescribeOptionsTraits>;
public:
GitDescribeOptions(git_describe_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDescribeOptions();
~GitDescribeOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetMaxCandidatesTags);
static NAN_SETTER(SetMaxCandidatesTags);
static NAN_GETTER(GetDescribeStrategy);
static NAN_SETTER(SetDescribeStrategy);
static NAN_GETTER(GetPattern);
static NAN_SETTER(SetPattern);
static NAN_GETTER(GetOnlyFollowFirstParent);
static NAN_SETTER(SetOnlyFollowFirstParent);
static NAN_GETTER(GetShowCommitOidAsFallback);
static NAN_SETTER(SetShowCommitOidAsFallback);
};
#endif
+73
View File
@@ -0,0 +1,73 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDESCRIBERESULT_H
#define GITDESCRIBERESULT_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
// Forward declaration.
struct git_describe_result {
};
using namespace node;
using namespace v8;
class GitDescribeResult;
struct GitDescribeResultTraits {
typedef GitDescribeResult cppClass;
typedef git_describe_result cType;
static const bool isDuplicable = false;
static void duplicate(git_describe_result **dest, git_describe_result *src) {
Nan::ThrowError("duplicate called on GitDescribeResult which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_describe_result *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDescribeResult : public
NodeGitWrapper<GitDescribeResultTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDescribeResultTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDescribeResult()
: NodeGitWrapper<GitDescribeResultTraits>(
"A new GitDescribeResult cannot be instantiated."
)
{}
GitDescribeResult(git_describe_result *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDescribeResultTraits>(raw, selfFreeing, owner)
{}
~GitDescribeResult();
};
#endif
+531
View File
@@ -0,0 +1,531 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFF_H
#define GITDIFF_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
#include <git2/sys/diff.h>
}
#include "../include/typedefs.h"
#include "../include/blob.h"
#include "../include/diff_options.h"
#include "../include/diff_delta.h"
#include "../include/diff_binary.h"
#include "../include/diff_hunk.h"
#include "../include/diff_line.h"
#include "../include/diff_find_options.h"
#include "../include/diff_stats.h"
#include "../include/repository.h"
#include "../include/index.h"
#include "../include/oid.h"
#include "../include/diff_patchid_options.h"
#include "../include/buf.h"
#include "../include/tree.h"
#include "../include/diff_perfdata.h"
// Forward declaration.
struct git_diff {
};
using namespace node;
using namespace v8;
class GitDiff;
struct GitDiffTraits {
typedef GitDiff cppClass;
typedef git_diff cType;
static const bool isDuplicable = false;
static void duplicate(git_diff **dest, git_diff *src) {
Nan::ThrowError("duplicate called on GitDiff which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_diff_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiff : public
NodeGitWrapper<GitDiffTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
static int BlobToBuffer_file_cb_cppCallback (
const git_diff_delta * delta
,
float progress
,
void * payload
);
static void BlobToBuffer_file_cb_async(void *baton);
static void BlobToBuffer_file_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct BlobToBuffer_FileCbBaton : public AsyncBatonWithResult<int> {
const git_diff_delta * delta;
float progress;
void * payload;
BlobToBuffer_FileCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static int BlobToBuffer_binary_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_binary * binary
,
void * payload
);
static void BlobToBuffer_binary_cb_async(void *baton);
static void BlobToBuffer_binary_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct BlobToBuffer_BinaryCbBaton : public AsyncBatonWithResult<int> {
const git_diff_delta * delta;
const git_diff_binary * binary;
void * payload;
BlobToBuffer_BinaryCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static int BlobToBuffer_hunk_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_hunk * hunk
,
void * payload
);
static void BlobToBuffer_hunk_cb_async(void *baton);
static void BlobToBuffer_hunk_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct BlobToBuffer_HunkCbBaton : public AsyncBatonWithResult<int> {
const git_diff_delta * delta;
const git_diff_hunk * hunk;
void * payload;
BlobToBuffer_HunkCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static int BlobToBuffer_line_cb_cppCallback (
const git_diff_delta * delta
,
const git_diff_hunk * hunk
,
const git_diff_line * line
,
void * payload
);
static void BlobToBuffer_line_cb_async(void *baton);
static void BlobToBuffer_line_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct BlobToBuffer_LineCbBaton : public AsyncBatonWithResult<int> {
const git_diff_delta * delta;
const git_diff_hunk * hunk;
const git_diff_line * line;
void * payload;
BlobToBuffer_LineCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
private:
GitDiff()
: NodeGitWrapper<GitDiffTraits>(
"A new GitDiff cannot be instantiated."
)
{}
GitDiff(git_diff *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffTraits>(raw, selfFreeing, owner)
{}
~GitDiff();
struct BlobToBufferBaton {
int error_code;
const git_error* error;
const git_blob * old_blob;
const char * old_as_path;
const char * buffer;
size_t buffer_len;
const char * buffer_as_path;
const git_diff_options * options;
git_diff_file_cb file_cb;
git_diff_binary_cb binary_cb;
git_diff_hunk_cb hunk_cb;
git_diff_line_cb line_cb;
void * payload;
};
class BlobToBufferWorker : public Nan::AsyncWorker {
public:
BlobToBufferWorker(
BlobToBufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~BlobToBufferWorker() {};
void Execute();
void HandleOKCallback();
private:
BlobToBufferBaton *baton;
};
static NAN_METHOD(BlobToBuffer);
struct FindSimilarBaton {
int error_code;
const git_error* error;
git_diff * diff;
const git_diff_find_options * options;
};
class FindSimilarWorker : public Nan::AsyncWorker {
public:
FindSimilarWorker(
FindSimilarBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FindSimilarWorker() {};
void Execute();
void HandleOKCallback();
private:
FindSimilarBaton *baton;
};
static NAN_METHOD(FindSimilar);
struct FromBufferBaton {
int error_code;
const git_error* error;
git_diff * out;
const char * content;
size_t content_len;
};
class FromBufferWorker : public Nan::AsyncWorker {
public:
FromBufferWorker(
FromBufferBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~FromBufferWorker() {};
void Execute();
void HandleOKCallback();
private:
FromBufferBaton *baton;
};
static NAN_METHOD(FromBuffer);
static NAN_METHOD(GetDelta);
struct GetStatsBaton {
int error_code;
const git_error* error;
git_diff_stats * out;
git_diff * diff;
};
class GetStatsWorker : public Nan::AsyncWorker {
public:
GetStatsWorker(
GetStatsBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~GetStatsWorker() {};
void Execute();
void HandleOKCallback();
private:
GetStatsBaton *baton;
};
static NAN_METHOD(GetStats);
struct IndexToIndexBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_index * old_index;
git_index * new_index;
const git_diff_options * opts;
};
class IndexToIndexWorker : public Nan::AsyncWorker {
public:
IndexToIndexWorker(
IndexToIndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~IndexToIndexWorker() {};
void Execute();
void HandleOKCallback();
private:
IndexToIndexBaton *baton;
};
static NAN_METHOD(IndexToIndex);
struct IndexToWorkdirBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_index * index;
const git_diff_options * opts;
};
class IndexToWorkdirWorker : public Nan::AsyncWorker {
public:
IndexToWorkdirWorker(
IndexToWorkdirBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~IndexToWorkdirWorker() {};
void Execute();
void HandleOKCallback();
private:
IndexToWorkdirBaton *baton;
};
static NAN_METHOD(IndexToWorkdir);
static NAN_METHOD(IsSortedIcase);
struct MergeBaton {
int error_code;
const git_error* error;
git_diff * onto;
const git_diff * from;
};
class MergeWorker : public Nan::AsyncWorker {
public:
MergeWorker(
MergeBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~MergeWorker() {};
void Execute();
void HandleOKCallback();
private:
MergeBaton *baton;
};
static NAN_METHOD(Merge);
static NAN_METHOD(NumDeltas);
struct PatchidBaton {
int error_code;
const git_error* error;
git_oid * out;
git_diff * diff;
git_diff_patchid_options * opts;
};
class PatchidWorker : public Nan::AsyncWorker {
public:
PatchidWorker(
PatchidBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~PatchidWorker() {};
void Execute();
void HandleOKCallback();
private:
PatchidBaton *baton;
};
static NAN_METHOD(Patchid);
struct ToBufBaton {
int error_code;
const git_error* error;
git_buf * out;
git_diff * diff;
git_diff_format_t format;
};
class ToBufWorker : public Nan::AsyncWorker {
public:
ToBufWorker(
ToBufBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~ToBufWorker() {};
void Execute();
void HandleOKCallback();
private:
ToBufBaton *baton;
};
static NAN_METHOD(ToBuf);
struct TreeToIndexBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
git_index * index;
const git_diff_options * opts;
};
class TreeToIndexWorker : public Nan::AsyncWorker {
public:
TreeToIndexWorker(
TreeToIndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToIndexWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToIndexBaton *baton;
};
static NAN_METHOD(TreeToIndex);
struct TreeToTreeBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
git_tree * new_tree;
const git_diff_options * opts;
};
class TreeToTreeWorker : public Nan::AsyncWorker {
public:
TreeToTreeWorker(
TreeToTreeBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToTreeWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToTreeBaton *baton;
};
static NAN_METHOD(TreeToTree);
struct TreeToWorkdirBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
const git_diff_options * opts;
};
class TreeToWorkdirWorker : public Nan::AsyncWorker {
public:
TreeToWorkdirWorker(
TreeToWorkdirBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToWorkdirWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToWorkdirBaton *baton;
};
static NAN_METHOD(TreeToWorkdir);
struct TreeToWorkdirWithIndexBaton {
int error_code;
const git_error* error;
git_diff * diff;
git_repository * repo;
git_tree * old_tree;
const git_diff_options * opts;
};
class TreeToWorkdirWithIndexWorker : public Nan::AsyncWorker {
public:
TreeToWorkdirWithIndexWorker(
TreeToWorkdirWithIndexBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~TreeToWorkdirWithIndexWorker() {};
void Execute();
void HandleOKCallback();
private:
TreeToWorkdirWithIndexBaton *baton;
};
static NAN_METHOD(TreeToWorkdirWithIndex);
static NAN_METHOD(GetPerfdata);
struct BlobToBuffer_globalPayload {
Nan::Callback * file_cb;
Nan::Callback * binary_cb;
Nan::Callback * hunk_cb;
Nan::Callback * line_cb;
BlobToBuffer_globalPayload() {
file_cb = NULL;
binary_cb = NULL;
hunk_cb = NULL;
line_cb = NULL;
}
~BlobToBuffer_globalPayload() {
if (file_cb != NULL) {
delete file_cb;
}
if (binary_cb != NULL) {
delete binary_cb;
}
if (hunk_cb != NULL) {
delete hunk_cb;
}
if (line_cb != NULL) {
delete line_cb;
}
}
};
};
#endif
+74
View File
@@ -0,0 +1,74 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFBINARY_H
#define GITDIFFBINARY_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/diff_binary_file.h"
using namespace node;
using namespace v8;
class GitDiffBinary;
struct GitDiffBinaryTraits {
typedef GitDiffBinary cppClass;
typedef git_diff_binary cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_binary **dest, git_diff_binary *src) {
Nan::ThrowError("duplicate called on GitDiffBinary which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_binary *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffBinary : public
NodeGitWrapper<GitDiffBinaryTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffBinaryTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffBinary()
: NodeGitWrapper<GitDiffBinaryTraits>(
"A new GitDiffBinary cannot be instantiated."
)
{}
GitDiffBinary(git_diff_binary *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffBinaryTraits>(raw, selfFreeing, owner)
{}
~GitDiffBinary();
static NAN_METHOD(ContainsData);
static NAN_METHOD(OldFile);
static NAN_METHOD(NewFile);
};
#endif
+74
View File
@@ -0,0 +1,74 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFBINARYFILE_H
#define GITDIFFBINARYFILE_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitDiffBinaryFile;
struct GitDiffBinaryFileTraits {
typedef GitDiffBinaryFile cppClass;
typedef git_diff_binary_file cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_binary_file **dest, git_diff_binary_file *src) {
Nan::ThrowError("duplicate called on GitDiffBinaryFile which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_binary_file *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffBinaryFile : public
NodeGitWrapper<GitDiffBinaryFileTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffBinaryFileTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffBinaryFile()
: NodeGitWrapper<GitDiffBinaryFileTraits>(
"A new GitDiffBinaryFile cannot be instantiated."
)
{}
GitDiffBinaryFile(git_diff_binary_file *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffBinaryFileTraits>(raw, selfFreeing, owner)
{}
~GitDiffBinaryFile();
static NAN_METHOD(Type);
static NAN_METHOD(Data);
static NAN_METHOD(Datalen);
static NAN_METHOD(Inflatedlen);
};
#endif
+77
View File
@@ -0,0 +1,77 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFDELTA_H
#define GITDIFFDELTA_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/diff_file.h"
using namespace node;
using namespace v8;
class GitDiffDelta;
struct GitDiffDeltaTraits {
typedef GitDiffDelta cppClass;
typedef git_diff_delta cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_delta **dest, git_diff_delta *src) {
Nan::ThrowError("duplicate called on GitDiffDelta which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_delta *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffDelta : public
NodeGitWrapper<GitDiffDeltaTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffDeltaTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffDelta()
: NodeGitWrapper<GitDiffDeltaTraits>(
"A new GitDiffDelta cannot be instantiated."
)
{}
GitDiffDelta(git_diff_delta *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffDeltaTraits>(raw, selfFreeing, owner)
{}
~GitDiffDelta();
static NAN_METHOD(Status);
static NAN_METHOD(Flags);
static NAN_METHOD(Similarity);
static NAN_METHOD(Nfiles);
static NAN_METHOD(OldFile);
static NAN_METHOD(NewFile);
};
#endif
+77
View File
@@ -0,0 +1,77 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFFILE_H
#define GITDIFFFILE_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/oid.h"
using namespace node;
using namespace v8;
class GitDiffFile;
struct GitDiffFileTraits {
typedef GitDiffFile cppClass;
typedef git_diff_file cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_file **dest, git_diff_file *src) {
Nan::ThrowError("duplicate called on GitDiffFile which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_file *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffFile : public
NodeGitWrapper<GitDiffFileTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffFileTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffFile()
: NodeGitWrapper<GitDiffFileTraits>(
"A new GitDiffFile cannot be instantiated."
)
{}
GitDiffFile(git_diff_file *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffFileTraits>(raw, selfFreeing, owner)
{}
~GitDiffFile();
static NAN_METHOD(Id);
static NAN_METHOD(Path);
static NAN_METHOD(Size);
static NAN_METHOD(Flags);
static NAN_METHOD(Mode);
static NAN_METHOD(IdAbbrev);
};
#endif
+88
View File
@@ -0,0 +1,88 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITDIFFFINDOPTIONS_H
#define GITDIFFFINDOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
using namespace node;
using namespace v8;
class GitDiffFindOptions;
struct GitDiffFindOptionsTraits {
typedef GitDiffFindOptions cppClass;
typedef git_diff_find_options cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_find_options **dest, git_diff_find_options *src) {
Nan::ThrowError("duplicate called on GitDiffFindOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_find_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffFindOptions : public NodeGitWrapper<GitDiffFindOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitDiffFindOptionsTraits>;
public:
GitDiffFindOptions(git_diff_find_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffFindOptions();
~GitDiffFindOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetFlags);
static NAN_SETTER(SetFlags);
static NAN_GETTER(GetRenameThreshold);
static NAN_SETTER(SetRenameThreshold);
static NAN_GETTER(GetRenameFromRewriteThreshold);
static NAN_SETTER(SetRenameFromRewriteThreshold);
static NAN_GETTER(GetCopyThreshold);
static NAN_SETTER(SetCopyThreshold);
static NAN_GETTER(GetBreakRewriteThreshold);
static NAN_SETTER(SetBreakRewriteThreshold);
static NAN_GETTER(GetRenameLimit);
static NAN_SETTER(SetRenameLimit);
};
#endif
+76
View File
@@ -0,0 +1,76 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFHUNK_H
#define GITDIFFHUNK_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitDiffHunk;
struct GitDiffHunkTraits {
typedef GitDiffHunk cppClass;
typedef git_diff_hunk cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_hunk **dest, git_diff_hunk *src) {
Nan::ThrowError("duplicate called on GitDiffHunk which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_hunk *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffHunk : public
NodeGitWrapper<GitDiffHunkTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffHunkTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffHunk()
: NodeGitWrapper<GitDiffHunkTraits>(
"A new GitDiffHunk cannot be instantiated."
)
{}
GitDiffHunk(git_diff_hunk *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffHunkTraits>(raw, selfFreeing, owner)
{}
~GitDiffHunk();
static NAN_METHOD(OldStart);
static NAN_METHOD(OldLines);
static NAN_METHOD(NewStart);
static NAN_METHOD(NewLines);
static NAN_METHOD(HeaderLen);
static NAN_METHOD(Header);
};
#endif
+77
View File
@@ -0,0 +1,77 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFLINE_H
#define GITDIFFLINE_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitDiffLine;
struct GitDiffLineTraits {
typedef GitDiffLine cppClass;
typedef git_diff_line cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_line **dest, git_diff_line *src) {
Nan::ThrowError("duplicate called on GitDiffLine which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_line *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffLine : public
NodeGitWrapper<GitDiffLineTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffLineTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffLine()
: NodeGitWrapper<GitDiffLineTraits>(
"A new GitDiffLine cannot be instantiated."
)
{}
GitDiffLine(git_diff_line *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffLineTraits>(raw, selfFreeing, owner)
{}
~GitDiffLine();
static NAN_METHOD(Origin);
static NAN_METHOD(OldLineno);
static NAN_METHOD(NewLineno);
static NAN_METHOD(NumLines);
static NAN_METHOD(ContentLen);
static NAN_METHOD(ContentOffset);
static NAN_METHOD(Content);
};
#endif
+166
View File
@@ -0,0 +1,166 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITDIFFOPTIONS_H
#define GITDIFFOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
#include "../include/strarray.h"
#include "../include/diff_delta.h"
using namespace node;
using namespace v8;
class GitDiffOptions;
struct GitDiffOptionsTraits {
typedef GitDiffOptions cppClass;
typedef git_diff_options cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_options **dest, git_diff_options *src) {
Nan::ThrowError("duplicate called on GitDiffOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffOptions : public NodeGitWrapper<GitDiffOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitDiffOptionsTraits>;
public:
GitDiffOptions(git_diff_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
static int notify_cb_cppCallback (
const git_diff * diff_so_far
,
git_diff_delta * delta_to_add
,
const char * matched_pathspec
,
void * payload
);
static void notify_cb_async(void *baton);
static void notify_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct NotifyCbBaton : public AsyncBatonWithResult<int> {
const git_diff * diff_so_far;
git_diff_delta * delta_to_add;
const char * matched_pathspec;
void * payload;
NotifyCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitDiffOptions * notify_cb_getInstanceFromBaton (
NotifyCbBaton *baton);
static int progress_cb_cppCallback (
const git_diff * diff_so_far
,
const char * old_path
,
const char * new_path
,
void * payload
);
static void progress_cb_async(void *baton);
static void progress_cb_promiseCompleted(bool isFulfilled, AsyncBaton *_baton, v8::Local<v8::Value> result);
struct ProgressCbBaton : public AsyncBatonWithResult<int> {
const git_diff * diff_so_far;
const char * old_path;
const char * new_path;
void * payload;
ProgressCbBaton(const int &defaultResult)
: AsyncBatonWithResult<int>(defaultResult) {
}
};
static GitDiffOptions * progress_cb_getInstanceFromBaton (
ProgressCbBaton *baton);
private:
GitDiffOptions();
~GitDiffOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
static NAN_GETTER(GetFlags);
static NAN_SETTER(SetFlags);
static NAN_GETTER(GetIgnoreSubmodules);
static NAN_SETTER(SetIgnoreSubmodules);
Nan::Persistent<Object> pathspec;
static NAN_GETTER(GetPathspec);
static NAN_SETTER(SetPathspec);
CallbackWrapper notify_cb;
static NAN_GETTER(GetNotifyCb);
static NAN_SETTER(SetNotifyCb);
CallbackWrapper progress_cb;
static NAN_GETTER(GetProgressCb);
static NAN_SETTER(SetProgressCb);
Nan::Persistent<Value> payload;
static NAN_GETTER(GetPayload);
static NAN_SETTER(SetPayload);
static NAN_GETTER(GetContextLines);
static NAN_SETTER(SetContextLines);
static NAN_GETTER(GetInterhunkLines);
static NAN_SETTER(SetInterhunkLines);
static NAN_GETTER(GetIdAbbrev);
static NAN_SETTER(SetIdAbbrev);
static NAN_GETTER(GetMaxSize);
static NAN_SETTER(SetMaxSize);
static NAN_GETTER(GetOldPrefix);
static NAN_SETTER(SetOldPrefix);
static NAN_GETTER(GetNewPrefix);
static NAN_SETTER(SetNewPrefix);
};
#endif
+64
View File
@@ -0,0 +1,64 @@
// This is a generated file, modify: generate/templates/templates/struct_header.h
#ifndef GITDIFFPATCHIDOPTIONS_H
#define GITDIFFPATCHIDOPTIONS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include "async_baton.h"
#include "callback_wrapper.h"
#include "reference_counter.h"
#include "nodegit_wrapper.h"
extern "C" {
#include <git2.h>
}
using namespace node;
using namespace v8;
class GitDiffPatchidOptions;
struct GitDiffPatchidOptionsTraits {
typedef GitDiffPatchidOptions cppClass;
typedef git_diff_patchid_options cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_patchid_options **dest, git_diff_patchid_options *src) {
Nan::ThrowError("duplicate called on GitDiffPatchidOptions which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_patchid_options *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffPatchidOptions : public NodeGitWrapper<GitDiffPatchidOptionsTraits> {
// grant full access to base class
friend class NodeGitWrapper<GitDiffPatchidOptionsTraits>;
public:
GitDiffPatchidOptions(git_diff_patchid_options* raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>());
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffPatchidOptions();
~GitDiffPatchidOptions();
void ConstructFields();
static NAN_GETTER(GetVersion);
static NAN_SETTER(SetVersion);
};
#endif
+73
View File
@@ -0,0 +1,73 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFPERFDATA_H
#define GITDIFFPERFDATA_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
#include <git2/sys/diff.h>
}
#include "../include/typedefs.h"
using namespace node;
using namespace v8;
class GitDiffPerfdata;
struct GitDiffPerfdataTraits {
typedef GitDiffPerfdata cppClass;
typedef git_diff_perfdata cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_perfdata **dest, git_diff_perfdata *src) {
Nan::ThrowError("duplicate called on GitDiffPerfdata which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_perfdata *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffPerfdata : public
NodeGitWrapper<GitDiffPerfdataTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffPerfdataTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffPerfdata()
: NodeGitWrapper<GitDiffPerfdataTraits>(
"A new GitDiffPerfdata cannot be instantiated."
)
{}
GitDiffPerfdata(git_diff_perfdata *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffPerfdataTraits>(raw, selfFreeing, owner)
{}
~GitDiffPerfdata();
static NAN_METHOD(StatCalls);
static NAN_METHOD(OidCalculations);
};
#endif
+105
View File
@@ -0,0 +1,105 @@
// This is a generated file, modify: generate/templates/templates/class_header.h
#ifndef GITDIFFSTATS_H
#define GITDIFFSTATS_H
#include <nan.h>
#include <string>
#include <queue>
#include <utility>
#include <unordered_map>
#include <sstream>
#include "async_baton.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
extern "C" {
#include <git2.h>
}
#include "../include/typedefs.h"
#include "../include/buf.h"
// Forward declaration.
struct git_diff_stats {
};
using namespace node;
using namespace v8;
class GitDiffStats;
struct GitDiffStatsTraits {
typedef GitDiffStats cppClass;
typedef git_diff_stats cType;
static const bool isDuplicable = false;
static void duplicate(git_diff_stats **dest, git_diff_stats *src) {
Nan::ThrowError("duplicate called on GitDiffStats which cannot be duplicated");
}
static const bool isSingleton = false;
static const bool isFreeable = true;
static void free(git_diff_stats *raw) {
unsigned long referenceCount = 0;
if (referenceCount == 0) {
::git_diff_stats_free(raw); // :: to avoid calling this free recursively
}
}
};
class GitDiffStats : public
NodeGitWrapper<GitDiffStatsTraits>
{
// grant full access to base class
friend class NodeGitWrapper<GitDiffStatsTraits>;
public:
static void InitializeComponent (v8::Local<v8::Object> target);
private:
GitDiffStats()
: NodeGitWrapper<GitDiffStatsTraits>(
"A new GitDiffStats cannot be instantiated."
)
{}
GitDiffStats(git_diff_stats *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
: NodeGitWrapper<GitDiffStatsTraits>(raw, selfFreeing, owner)
{}
~GitDiffStats();
static NAN_METHOD(FilesChanged);
static NAN_METHOD(Insertions);
static NAN_METHOD(Deletions);
struct DiffStatsToBufBaton {
int error_code;
const git_error* error;
git_buf * out;
const git_diff_stats * stats;
git_diff_stats_format_t format;
size_t width;
};
class DiffStatsToBufWorker : public Nan::AsyncWorker {
public:
DiffStatsToBufWorker(
DiffStatsToBufBaton *_baton,
Nan::Callback *callback
) : Nan::AsyncWorker(callback)
, baton(_baton) {};
~DiffStatsToBufWorker() {};
void Execute();
void HandleOKCallback();
private:
DiffStatsToBufBaton *baton;
};
static NAN_METHOD(DiffStatsToBuf);
};
#endif

Some files were not shown because too many files have changed in this diff Show More