| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ | |||
| 34 | 34 | 'src/odb.cc', | |
| 35 | 35 | 'src/submodule.cc', | |
| 36 | 36 | 'src/remote.cc', | |
| 37 | + 'src/clone_options.cc', | ||
| 37 | 38 | 'src/functions/copy.cc', | |
| 38 | 39 | ||
| 39 | 40 | ], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,27 @@ | |||
| 1 | + var git = require('../'), | ||
| 2 | + rimraf = require('rimraf'), | ||
| 3 | + path = "/tmp/nodegit-clone-demo"; | ||
| 4 | + | ||
| 5 | + rimraf(path, function() { | ||
| 6 | + git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) { | ||
| 7 | + if (error) throw error; | ||
| 8 | + | ||
| 9 | + repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) { | ||
| 10 | + if (error) throw error; | ||
| 11 | + | ||
| 12 | + commit.getEntry('README.md', function(error, entry) { | ||
| 13 | + if (error) throw error; | ||
| 14 | + | ||
| 15 | + entry.getBlob(function(error, blob) { | ||
| 16 | + if (error) throw error; | ||
| 17 | + | ||
| 18 | + console.log(entry.name(), entry.sha(), blob.size() + 'b'); | ||
| 19 | + console.log('========================================================\n\n'); | ||
| 20 | + var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n'); | ||
| 21 | + console.log(firstTenLines); | ||
| 22 | + console.log('...'); | ||
| 23 | + }); | ||
| 24 | + }); | ||
| 25 | + }); | ||
| 26 | + }); | ||
| 27 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + var git = require('../'), | ||
| 2 | + path = require('path'); | ||
| 3 | + | ||
| 4 | + git.Repo.open(path.resolve(__dirname, '../.git'), function(error, repo) { | ||
| 5 | + if (error) throw error; | ||
| 6 | + | ||
| 7 | + var remote = repo.getRemote("origin"); | ||
| 8 | + remote.connect(0, function(error) { | ||
| 9 | + if (error) throw error; | ||
| 10 | + | ||
| 11 | + remote.download(null, function(error) { | ||
| 12 | + if (error) throw error; | ||
| 13 | + | ||
| 14 | + console.log("It worked!"); | ||
| 15 | + }) | ||
| 16 | + }); | ||
| 17 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,37 @@ | |||
| 1 | + /** | ||
| 2 | + * This code is auto-generated; unless you know what you're doing, do not modify! | ||
| 3 | + **/ | ||
| 4 | + | ||
| 5 | + #ifndef GITCLONEOPTIONS_H | ||
| 6 | + #define GITCLONEOPTIONS_H | ||
| 7 | + | ||
| 8 | + #include <v8.h> | ||
| 9 | + #include <node.h> | ||
| 10 | + #include <string> | ||
| 11 | + | ||
| 12 | + #include "git2.h" | ||
| 13 | + | ||
| 14 | + using namespace node; | ||
| 15 | + using namespace v8; | ||
| 16 | + | ||
| 17 | + class GitCloneOptions : public ObjectWrap { | ||
| 18 | + public: | ||
| 19 | + | ||
| 20 | + static Persistent<Function> constructor_template; | ||
| 21 | + static void Initialize (Handle<v8::Object> target); | ||
| 22 | + | ||
| 23 | + git_clone_options *GetValue(); | ||
| 24 | + | ||
| 25 | + static Handle<Value> New(void *raw); | ||
| 26 | + | ||
| 27 | + private: | ||
| 28 | + GitCloneOptions(git_clone_options *raw); | ||
| 29 | + ~GitCloneOptions(); | ||
| 30 | + | ||
| 31 | + static Handle<Value> New(const Arguments& args); | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + git_clone_options *raw; | ||
| 35 | + }; | ||
| 36 | + | ||
| 37 | + #endif | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,22 @@ class GitRemote : public ObjectWrap { | |||
| 50 | 50 | git_direction direction; | |
| 51 | 51 | Persistent<Function> callback; | |
| 52 | 52 | }; | |
| 53 | + static Handle<Value> Download(const Arguments& args); | ||
| 54 | + static void DownloadWork(uv_work_t* req); | ||
| 55 | + static void DownloadAfterWork(uv_work_t* req); | ||
| 56 | + | ||
| 57 | + struct DownloadBaton { | ||
| 58 | + uv_work_t request; | ||
| 59 | + int error_code; | ||
| 60 | + const git_error* error; | ||
| 61 | + Persistent<Value> remoteReference; | ||
| 62 | + git_remote * remote; | ||
| 63 | + Persistent<Value> progress_cbReference; | ||
| 64 | + git_transfer_progress_callback progress_cb; | ||
| 65 | + Persistent<Value> payloadReference; | ||
| 66 | + void * payload; | ||
| 67 | + Persistent<Function> callback; | ||
| 68 | + }; | ||
| 53 | 69 | static Handle<Value> Connected(const Arguments& args); | |
| 54 | 70 | static Handle<Value> Stop(const Arguments& args); | |
| 55 | 71 | static Handle<Value> Disconnect(const Arguments& args); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -346,6 +346,24 @@ class GitRepo : public ObjectWrap { | |||
| 346 | 346 | git_repository * repo; | |
| 347 | 347 | Persistent<Function> callback; | |
| 348 | 348 | }; | |
| 349 | + static Handle<Value> Clone(const Arguments& args); | ||
| 350 | + static void CloneWork(uv_work_t* req); | ||
| 351 | + static void CloneAfterWork(uv_work_t* req); | ||
| 352 | + | ||
| 353 | + struct CloneBaton { | ||
| 354 | + uv_work_t request; | ||
| 355 | + int error_code; | ||
| 356 | + const git_error* error; | ||
| 357 | + git_repository * out; | ||
| 358 | + Persistent<Value> urlReference; | ||
| 359 | + const char * url; | ||
| 360 | + Persistent<Value> local_pathReference; | ||
| 361 | + const char * local_path; | ||
| 362 | + Persistent<Value> optionsReference; | ||
| 363 | + const git_clone_options * options; | ||
| 364 | + Persistent<Function> callback; | ||
| 365 | + }; | ||
| 366 | + static Handle<Value> GetRemote(const Arguments& args); | ||
| 349 | 367 | git_repository *raw; | |
| 350 | 368 | }; | |
| 351 | 369 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ | |||
| 40 | 40 | #include "../include/submodule.h" | |
| 41 | 41 | #include "../include/tree_builder.h" | |
| 42 | 42 | #include "../include/remote.h" | |
| 43 | + #include "../include/clone_options.h" | ||
| 43 | 44 | ||
| 44 | 45 | extern "C" void init(Handle<v8::Object> target) { | |
| 45 | 46 | HandleScope scope; | |
@@ -76,6 +77,9 @@ extern "C" void init(Handle<v8::Object> target) { | |||
| 76 | 77 | GitDiffFile::Initialize(target); | |
| 77 | 78 | GitDelta::Initialize(target); | |
| 78 | 79 | ||
| 80 | + GitRemote::Initialize(target); | ||
| 81 | + GitCloneOptions::Initialize(target); | ||
| 82 | + | ||
| 79 | 83 | GitThreads::Initialize(target); | |
| 80 | 84 | ||
| 81 | 85 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments