| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ var path = require('path'); | |||
| 3 | 3 | var Promise = require('nodegit-promise'); | |
| 4 | 4 | var promisify = require('promisify-node'); | |
| 5 | 5 | var fse = promisify(require('fs-extra')); | |
| 6 | - var mkdirp = promisify(require('mkdirp')); | ||
| 7 | 6 | var fileName = 'newfile.txt'; | |
| 8 | 7 | var fileContent = 'hello world'; | |
| 9 | 8 | var directoryName = 'salad/toast/strangerinastrangeland/theresnowaythisexists'; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,57 @@ | |||
| 1 | + var nodegit = require('../'); | ||
| 2 | + var path = require('path'); | ||
| 3 | + var Promise = require('nodegit-promise'); | ||
| 4 | + var promisify = require('promisify-node'); | ||
| 5 | + var fse = promisify(require('fs-extra')); | ||
| 6 | + var fileName = 'newfile.txt'; | ||
| 7 | + var fileContent = 'hello world'; | ||
| 8 | + var repoDir = '../../newRepo'; | ||
| 9 | + | ||
| 10 | + fse.ensureDir = promisify(fse.ensureDir); | ||
| 11 | + | ||
| 12 | + var repository; | ||
| 13 | + var index; | ||
| 14 | + | ||
| 15 | + fse.ensureDir(path.resolve(__dirname, repoDir)) | ||
| 16 | + .then(function() { | ||
| 17 | + console.log('a'); | ||
| 18 | + return nodegit.Repository.init(path.resolve(__dirname, repoDir), 0); | ||
| 19 | + }) | ||
| 20 | + .then(function(repo) { | ||
| 21 | + console.log('b'); | ||
| 22 | + repository = repo; | ||
| 23 | + return fse.writeFile(path.join(repository.workdir(), fileName), fileContent); | ||
| 24 | + }) | ||
| 25 | + .then(function(){ | ||
| 26 | + console.log('c'); | ||
| 27 | + return repository.openIndex(); | ||
| 28 | + }) | ||
| 29 | + .then(function(idx) { | ||
| 30 | + console.log('d'); | ||
| 31 | + index = idx; | ||
| 32 | + return index.read(1); | ||
| 33 | + }) | ||
| 34 | + .then(function() { | ||
| 35 | + console.log('e'); | ||
| 36 | + return index.addByPath(fileName); | ||
| 37 | + }) | ||
| 38 | + .then(function() { | ||
| 39 | + console.log('f'); | ||
| 40 | + return index.write(); | ||
| 41 | + }) | ||
| 42 | + .then(function() { | ||
| 43 | + console.log('g'); | ||
| 44 | + return index.writeTree(); | ||
| 45 | + }) | ||
| 46 | + .then(function(oid) { | ||
| 47 | + console.log('j'); | ||
| 48 | + var author = nodegit.Signature.create("Scott Chacon", "schacon@gmail.com", 123456789, 60); | ||
| 49 | + var committer = nodegit.Signature.create("Scott A Chacon", "scott@github.com", 987654321, 90); | ||
| 50 | + | ||
| 51 | + // Since we're creating an inital commit, it has no parents. Note that unlike | ||
| 52 | + // normal we don't get the head either, because there isn't one yet. | ||
| 53 | + return repository.createCommit('HEAD', author, committer, 'message', oid, []); | ||
| 54 | + }) | ||
| 55 | + .done(function(commitId) { | ||
| 56 | + console.log('New Commit: ', commitId); | ||
| 57 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,9 @@ | |||
| 34 | 34 | } | |
| 35 | 35 | } | |
| 36 | 36 | }, | |
| 37 | + "repository_init_flag": { | ||
| 38 | + "removeString": "INIT_" | ||
| 39 | + }, | ||
| 37 | 40 | "otype": { | |
| 38 | 41 | "JsName": "TYPE", | |
| 39 | 42 | "owner": "Object", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments