From 47f20d8a73163d8a68fad3e783208040acf8e837 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Thu, 25 Jan 2018 22:52:30 -0700 Subject: [PATCH 01/25] resolves #1433 TreeEntry#path should return posix path --- lib/tree_entry.js | 2 +- test/tests/tree.js | 3 +-- test/tests/tree_entry.js | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/tree_entry.js b/lib/tree_entry.js index a65d85172..b9bc0fd72 100644 --- a/lib/tree_entry.js +++ b/lib/tree_entry.js @@ -1,4 +1,4 @@ -var path = require("path"); +var path = require("path").posix; var NodeGit = require("../"); var TreeEntry = NodeGit.TreeEntry; diff --git a/test/tests/tree.js b/test/tests/tree.js index aa98d4f3d..0790759f5 100644 --- a/test/tests/tree.js +++ b/test/tests/tree.js @@ -44,8 +44,7 @@ describe("Tree", function() { var repo = this.repository; var file1 = "test.txt"; var file2 = "foo/bar.txt"; - // index.addByPath doesn't like \s so normalize only for the expected paths - var expectedPaths = [file1, path.normalize(file2)]; + var expectedPaths = [file1, file2]; var progressEntries = []; var endEntries; diff --git a/test/tests/tree_entry.js b/test/tests/tree_entry.js index 13093fdaa..086a4f8d2 100644 --- a/test/tests/tree_entry.js +++ b/test/tests/tree_entry.js @@ -57,7 +57,7 @@ describe("TreeEntry", function() { it("provides the full path", function() { return this.commit.getEntry("test/raw-commit.js") .then(function(entry) { - assert.equal(entry.path(), path.normalize("test/raw-commit.js")); + assert.equal(entry.path(), "test/raw-commit.js"); }); }); @@ -66,7 +66,7 @@ describe("TreeEntry", function() { var dir = _dir || "", testPromises = []; tree.entries().forEach(function(entry) { - var currentPath = path.join(dir, entry.name()); + var currentPath = path.posix.join(dir, entry.name()); if (entry.isTree()) { testPromises.push( entry.getTree().then(function (subtree) { From 06036580127ae7806ee38d932505a964a284ed29 Mon Sep 17 00:00:00 2001 From: Croydon Date: Tue, 27 Feb 2018 18:50:24 +0100 Subject: [PATCH 02/25] Travis: Fix coveralls execution and documentation deploy --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 891a60818..df07e9b7c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -57,7 +57,7 @@ before_install: - nvm install $NODE_VERSION - - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [ $NODE_VERSION == "6" ]; then + - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]]; then export GYP_DEFINES="coverage=1 use_obsolete_asm=true"; export CC=/usr/bin/gcc-4.9; export CXX=/usr/bin/g++-4.9; @@ -83,7 +83,7 @@ before_script: - git config --global user.email johndoe@example.com script: - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [ $NODE_VERSION == "6" ]; then + if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]]; then travis_retry npm test && npm run cov && npm run coveralls; else travis_retry npm test; @@ -98,7 +98,7 @@ after_success: node-pre-gyp publish --target_arch=$TARGET_ARCH; fi - - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_OS_NAME == "linux" ] && [ $NODE_VERSION == "6" ] && [ $TARGET_ARCH == "x64" ]; then + - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]] && [ $TARGET_ARCH == "x64" ]; then .travis/deploy-docs.sh; fi From 78deec20c84a3c5699052b94cf3f2f1f4fa35283 Mon Sep 17 00:00:00 2001 From: Croydon Date: Tue, 27 Feb 2018 22:02:03 +0100 Subject: [PATCH 03/25] Travis: Simplify Node installing and version matrix --- .travis.yml | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index df07e9b7c..0730750f4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +sudo: false + branches: only: - master @@ -5,30 +7,25 @@ branches: compiler: clang +env: + - TARGET_ARCH="x64" + - TARGET_ARCH="ia32" + +language: node_js +node_js: + - "9.6" + - "8.9" + - "7.10" + - "6.13" + os: - linux - osx -sudo: false - -env: - matrix: - - export NODE_VERSION="9.6" TARGET_ARCH="x64" - - export NODE_VERSION="8.9" TARGET_ARCH="x64" - - export NODE_VERSION="7.10" TARGET_ARCH="x64" - - export NODE_VERSION="6.13" TARGET_ARCH="x64" - -matrix: - fast_finish: true - include: - - os: linux - env: export NODE_VERSION="9.6" TARGET_ARCH="ia32" - - os: linux - env: export NODE_VERSION="8.9" TARGET_ARCH="ia32" - - os: linux - env: export NODE_VERSION="7.10" TARGET_ARCH="ia32" - - os: linux - env: export NODE_VERSION="6.13" TARGET_ARCH="ia32" +jobs: + exclude: + - os: osx + env: TARGET_ARCH="ia32" git: depth: 1 @@ -50,14 +47,7 @@ before_install: - export npm_config_clang=1 - export JOBS=4 - - if [ $TRAVIS_OS_NAME != "linux" ]; then - git clone https://github.com/creationix/nvm.git ./.nvm; - source ./.nvm/nvm.sh; - fi - - - nvm install $NODE_VERSION - - - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]]; then + - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]]; then export GYP_DEFINES="coverage=1 use_obsolete_asm=true"; export CC=/usr/bin/gcc-4.9; export CXX=/usr/bin/g++-4.9; @@ -83,7 +73,7 @@ before_script: - git config --global user.email johndoe@example.com script: - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]]; then + if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]]; then travis_retry npm test && npm run cov && npm run coveralls; else travis_retry npm test; @@ -98,7 +88,7 @@ after_success: node-pre-gyp publish --target_arch=$TARGET_ARCH; fi - - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $NODE_VERSION == "8"* ]] && [ $TARGET_ARCH == "x64" ]; then + - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]] && [ $TARGET_ARCH == "x64" ]; then .travis/deploy-docs.sh; fi From f471a22206138c0dd92459e80aa4144a14d239f4 Mon Sep 17 00:00:00 2001 From: Croydon Date: Tue, 27 Feb 2018 22:14:23 +0100 Subject: [PATCH 04/25] Travis: Give extended testing and doc deploying an own stage --- .travis.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0730750f4..2da6fada9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,17 @@ branches: - /^v\d+\.\d+\.\d+$/ compiler: clang +language: node_js + +# Stage order; the default stage is "test", which in our case is actually building and deploying +stages: + - "Extended testing & documentation deploying" + - test env: - TARGET_ARCH="x64" - TARGET_ARCH="ia32" -language: node_js node_js: - "9.6" - "8.9" @@ -26,6 +31,12 @@ jobs: exclude: - os: osx env: TARGET_ARCH="ia32" + include: + - stage: "Extended testing & documentation deploying" + os: linux + node_js: "8.9" + env: TARGET_ARCH="x64" EXTENDED_TESTING="true" + git: depth: 1 @@ -47,7 +58,7 @@ before_install: - export npm_config_clang=1 - export JOBS=4 - - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]]; then + - if [ -z "$TRAVIS_TAG" ] && [ $EXTENDED_TESTING == "true" ]; then export GYP_DEFINES="coverage=1 use_obsolete_asm=true"; export CC=/usr/bin/gcc-4.9; export CXX=/usr/bin/g++-4.9; @@ -73,7 +84,7 @@ before_script: - git config --global user.email johndoe@example.com script: - if [ -z "$TRAVIS_TAG" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]]; then + if [ -z "$TRAVIS_TAG" ] && [ $EXTENDED_TESTING == "true" ]; then travis_retry npm test && npm run cov && npm run coveralls; else travis_retry npm test; @@ -88,7 +99,7 @@ after_success: node-pre-gyp publish --target_arch=$TARGET_ARCH; fi - - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $TRAVIS_OS_NAME == "linux" ] && [[ $TRAVIS_NODE_VERSION == "8"* ]] && [ $TARGET_ARCH == "x64" ]; then + - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $EXTENDED_TESTING == "true" ]; then .travis/deploy-docs.sh; fi From 6ccc46b64fe4c6d2fa0fbd4d2f067f0a5cef0b8d Mon Sep 17 00:00:00 2001 From: Croydon Date: Tue, 27 Feb 2018 22:19:10 +0100 Subject: [PATCH 05/25] Travis: Increase depth of cloning 1 is too low and causes already running builds to fail if you push new commits, there are no good reasons for this confusing behaviour --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2da6fada9..b9bcb14ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ jobs: git: - depth: 1 + depth: 5 addons: apt: From aa24124522d55875ec5593f3d2c6243f87ce3e7e Mon Sep 17 00:00:00 2001 From: Croydon Date: Tue, 27 Feb 2018 23:08:19 +0100 Subject: [PATCH 06/25] Travis: Always use latest minor release of major --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index b9bcb14ef..1d042e318 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,10 +18,10 @@ env: - TARGET_ARCH="ia32" node_js: - - "9.6" - - "8.9" - - "7.10" - - "6.13" + - "9" + - "8" + - "7" + - "6" os: - linux @@ -34,7 +34,7 @@ jobs: include: - stage: "Extended testing & documentation deploying" os: linux - node_js: "8.9" + node_js: "8" env: TARGET_ARCH="x64" EXTENDED_TESTING="true" From 9d874f5350080c06cd099c86ed6c6ea68ac11594 Mon Sep 17 00:00:00 2001 From: Croydon Date: Wed, 28 Feb 2018 13:54:59 +0100 Subject: [PATCH 07/25] Travis: Split extended testing and documentation deploy stage --- .travis.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1d042e318..031ee06e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,9 @@ language: node_js # Stage order; the default stage is "test", which in our case is actually building and deploying stages: - - "Extended testing & documentation deploying" + - "Extended testing" - test + - "Deploy documentation" env: - TARGET_ARCH="x64" @@ -32,10 +33,14 @@ jobs: - os: osx env: TARGET_ARCH="ia32" include: - - stage: "Extended testing & documentation deploying" + - stage: "Extended testing" os: linux node_js: "8" env: TARGET_ARCH="x64" EXTENDED_TESTING="true" + - stage: "Deploy documentation" + os: linux + node_js: "8" + env: TARGET_ARCH="x64" DEPLOY_DOCUMENTATION="true" git: @@ -99,7 +104,7 @@ after_success: node-pre-gyp publish --target_arch=$TARGET_ARCH; fi - - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $EXTENDED_TESTING == "true" ]; then + - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $DEPLOY_DOCUMENTATION == "true" ]; then .travis/deploy-docs.sh; fi From c2e8838b260a27afe9468d6042666ee7fa5d87f1 Mon Sep 17 00:00:00 2001 From: Croydon Date: Wed, 28 Feb 2018 14:02:47 +0100 Subject: [PATCH 08/25] Travis: Disable tests for now See issue #1449 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 031ee06e2..a4da2b6ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ jobs: - stage: "Extended testing" os: linux node_js: "8" - env: TARGET_ARCH="x64" EXTENDED_TESTING="true" + env: TARGET_ARCH="x64" EXTENDED_TESTING="false" - stage: "Deploy documentation" os: linux node_js: "8" From 1dec337743a7928c22f525faa025050945699728 Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Sun, 4 Mar 2018 16:24:15 +0900 Subject: [PATCH 09/25] Added tests for Tag targetId owner Signed-off-by: Remy Suen --- test/tests/tag.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/tests/tag.js b/test/tests/tag.js index 55f1d71e4..e7b485a1d 100644 --- a/test/tests/tag.js +++ b/test/tests/tag.js @@ -230,4 +230,21 @@ describe("Tag", function() { assert.equal(object.isCommit(), true); }); }); + + it("can get tag's target id", function() { + return this.repository.getTagByName(tagName) + .then(function(tag) { + assert.equal(commitPointedTo, tag.targetId()); + }); + }); + + it("can get tag's owner", function() { + var repository = this.repository; + return this.repository.getTagByName(tagName) + .then(function(tag) { + var owner = tag.owner(); + assert.ok(owner instanceof Repository); + assert.equal(repository.path(), owner.path()); + }); + }); }); From f725ac5950b0ba7fb126c0845212f1a78377a62e Mon Sep 17 00:00:00 2001 From: Croydon Date: Mon, 5 Mar 2018 19:04:59 +0100 Subject: [PATCH 10/25] Drop Node.js 7 (fix #1446) --- .travis.yml | 1 - appveyor.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a4da2b6ae..d8daee73e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,6 @@ env: node_js: - "9" - "8" - - "7" - "6" os: diff --git a/appveyor.yml b/appveyor.yml index fb0c1a02c..acbc2bcc9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,7 +28,6 @@ environment: # Node.js - nodejs_version: "9" - nodejs_version: "8" - - nodejs_version: "7" - nodejs_version: "6" matrix: From a76a79fb1b48c24f24b31e2cc25f360c8d4ff908 Mon Sep 17 00:00:00 2001 From: Remy Suen Date: Tue, 6 Mar 2018 18:46:14 +0900 Subject: [PATCH 11/25] Fix two small typos in CHANGELOG.md Signed-off-by: Remy Suen --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41cf4aa5e..05c457c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,7 +117,7 @@ - [Add CI build config for node stable version #1337](https://github.com/nodegit/nodegit/pull/1337) - [removed node v4 tests #1330](https://github.com/nodegit/nodegit/pull/1330) -#### Included merged libgti2 PRs: +#### Included merged libgit2 PRs: - [Include fixups #4288](https://github.com/libgit2/libgit2/pull/4288) - [Docs: Fix inline comments for git_diff_hunk #4330](https://github.com/libgit2/libgit2/pull/4330) - [oid: use memcmp in git_oid__hashcmp #4328](https://github.com/libgit2/libgit2/pull/4328) @@ -193,7 +193,7 @@ #### Summary of changes outside of libgit2 bump: - You can now convert tree entries in blobs [PR #1272](https://github.com/nodegit/nodegit/pull/1272) -#### Included merged libgti2 PRs: +#### Included merged libgit2 PRs: - [fileops: fix leaking fd in `mmap_ro_file` #4201](https://github.com/libgit2/libgit2/pull/4201) - [README: document our relation to changes in upstream #4198](https://github.com/libgit2/libgit2/pull/4198) From e06cca672c0be297f99dd52af93e01c54f5f1a01 Mon Sep 17 00:00:00 2001 From: AJ Jordan Date: Wed, 7 Mar 2018 10:27:33 -0500 Subject: [PATCH 12/25] Fix typo in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05c457c79..aa0743e03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ - [Fix details-for-tree-entry.js to access fields instead of calling a function #1326](https://github.com/nodegit/nodegit/pull/1326) - [Add JavaScript version of `git_tag_peel()` #1269](https://github.com/nodegit/nodegit/pull/1269) - [Fixed documentation error #1417](https://github.com/nodegit/nodegit/pull/1417) - - [Annoate Blame.file as async #1421](https://github.com/nodegit/nodegit/pull/1421) + - [Annotate Blame.file as async #1421](https://github.com/nodegit/nodegit/pull/1421) - [Add two missing tests to Commit #1422](https://github.com/nodegit/nodegit/pull/1422) - [CI: Update Node.js versions + some deps #1444](https://github.com/nodegit/nodegit/pull/1444) - [Expose fetch_options.custom_headers #1430](https://github.com/nodegit/nodegit/pull/1430) From 72644a6628a679896c3d081b2698eb20898e0a03 Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Mon, 12 Mar 2018 15:19:52 -0700 Subject: [PATCH 13/25] Handle fast-forward merges in repository.performRebase --- lib/repository.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 56d2f5a6f..6b7422114 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -204,9 +204,18 @@ function performRebase( ) { var beforeNextFnResult; - function readRebaseMetadataFile(fileName) { + /* In the case of FF merges, this will fail + * when looking for 'rewritten' so we need + * to handle that case. + */ + function readRebaseMetadataFile(fileName, determineExistance) { + const fullPath = path.join(repository.path(), "rebase-merge", fileName); + if (determineExistance && !fse.existsSync(fullPath)) { + return Promise.resolve(null); + } + return fse.readFile( - path.join(repository.path(), "rebase-merge", fileName), + fullPath, { encoding: "utf8" } ) .then(fp.trim); @@ -241,6 +250,10 @@ function performRebase( .catch(function(error) { if (error && error.errno === NodeGit.Error.CODE.ITEROVER) { const calcRewritten = fp.flow([ + fp.cond([ + [fp.isEmpty, fp.constant("")], + [fp.stubTrue, fp.identity] + ]), fp.split("\n"), fp.map(fp.split(" ")) ]); @@ -252,7 +265,7 @@ function performRebase( readRebaseMetadataFile("onto"), readRebaseMetadataFile("head-name").then(calcHeadName), readRebaseMetadataFile("orig-head"), - readRebaseMetadataFile("rewritten").then(calcRewritten) + readRebaseMetadataFile("rewritten", true).then(calcRewritten) ]) .then(function([ ontoName, From 1c334c67e462e7c615516a768a665ec0e85998ca Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Tue, 13 Mar 2018 10:02:29 -0700 Subject: [PATCH 14/25] Added a unit test and better comments --- lib/repository.js | 18 +++-- test/tests/rebase.js | 164 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+), 10 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 6b7422114..3a94b38a9 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -204,9 +204,8 @@ function performRebase( ) { var beforeNextFnResult; - /* In the case of FF merges, this will fail - * when looking for 'rewritten' so we need - * to handle that case. + /* In the case of FF merges and a beforeFinishFn, this will fail + * when looking for 'rewritten' so we need to handle that case. */ function readRebaseMetadataFile(fileName, determineExistance) { const fullPath = path.join(repository.path(), "rebase-merge", fileName); @@ -249,13 +248,12 @@ function performRebase( }) .catch(function(error) { if (error && error.errno === NodeGit.Error.CODE.ITEROVER) { - const calcRewritten = fp.flow([ - fp.cond([ - [fp.isEmpty, fp.constant("")], - [fp.stubTrue, fp.identity] - ]), - fp.split("\n"), - fp.map(fp.split(" ")) + const calcRewritten = fp.cond([ + [fp.isEmpty, fp.constant(null)], + [fp.stubTrue, fp.flow([ + fp.split("\n"), + fp.map(fp.split(" ")) + ])] ]); const beforeFinishFnPromise = !beforeFinishFn ? diff --git a/test/tests/rebase.js b/test/tests/rebase.js index d121a6c0f..f9dd3d2a2 100644 --- a/test/tests/rebase.js +++ b/test/tests/rebase.js @@ -6,6 +6,8 @@ var fse = promisify(require("fs-extra")); describe("Rebase", function() { var NodeGit = require("../../"); + var Checkout = NodeGit.Checkout; + var Merge = NodeGit.Merge; var RepoUtils = require("../utils/repository_setup"); var repoPath = local("../repos/rebase"); @@ -790,6 +792,168 @@ describe("Rebase", function() { }); }); + it( + "can fast-forward a merge commit via rebase using the " + + "convenience methods that has a beforeFinishFn", + function() { + var ourFileName = "ourNewFile.txt"; + var theirFileName = "theirNewFile.txt"; + var theirOtherFileName = "antherNewFile.txt"; + + var ourFileContent = "I like Toll Roads. I have an EZ-Pass!"; + var theirFileContent = "I'm skeptical about Toll Roads"; + var theirOtherFileContent = "This is some more content, guys!"; + + var ourSignature = NodeGit.Signature.create + ("Ron Paul", "RonPaul@TollRoadsRBest.info", 123456789, 60); + var theirSignature = NodeGit.Signature.create + ("Greg Abbott", "Gregggg@IllTollYourFace.us", 123456789, 60); + var theirOtherSignature = NodeGit.Signature.create + ("Greg Abbott", "Gregggg@IllTollYourFace.us", 123456999, 60); + var ourMergeSignature = NodeGit.Signature.create + ("Ron Paul", "RonPaul@TollRoadsRBest.info", 123456889, 60); + + var repository = this.repository; + var ourCommit; + var theirCommit; + var theirBranch; + var ourBranch; + + return fse.writeFile(path.join(repository.workdir(), ourFileName), + ourFileContent) + // Load up the repository index and make our initial commit to HEAD + .then(function() { + return RepoUtils.addFileToIndex(repository, ourFileName); + }) + .then(function(oid) { + assert.equal(oid.toString(), + "11ead82b1135b8e240fb5d61e703312fb9cc3d6a"); + + return repository.createCommit("HEAD", ourSignature, + ourSignature, "we made a commit", oid, []); + }) + .then(function(commitOid) { + assert.equal(commitOid.toString(), + "91a183f87842ebb7a9b08dad8bc2473985796844"); + + return repository.getCommit(commitOid).then(function(commit) { + ourCommit = commit; + }).then(function() { + return repository.createBranch(ourBranchName, commitOid) + .then(function(branch) { + ourBranch = branch; + return repository.createBranch(theirBranchName, commitOid); + }); + }); + }) + .then(function(branch) { + theirBranch = branch; + return fse.writeFile(path.join(repository.workdir(), theirFileName), + theirFileContent); + }) + .then(function() { + return RepoUtils.addFileToIndex(repository, theirFileName); + }) + .then(function(oid) { + assert.equal(oid.toString(), + "76631cb5a290dafe2959152626bb90f2a6d8ec94"); + + return repository.createCommit(theirBranch.name(), theirSignature, + theirSignature, "they made a commit", oid, [ourCommit]); + }) + .then(function(commitOid) { + theirCommit = commitOid; + assert.equal(commitOid.toString(), + "0e9231d489b3f4303635fc4b0397830da095e7e7"); + }) + .then(function() { + return repository.checkoutBranch( + ourBranch, + { checkoutStrategy: Checkout.STRATEGY.FORCE } + ); + }) + .then(function() { + return repository.mergeBranches( + ourBranchName, + theirBranchName, + ourMergeSignature, + Merge.PREFERENCE.NO_FASTFORWARD + ); + }) + .then(function() { + return repository.getHeadCommit(); + }) + .then(function(headCommit) { + assert.notEqual(ourCommit.id().toString(), headCommit.id().toString()); + }) + .then(function() { + return repository.checkoutBranch( + theirBranch, + { checkoutStrategy: Checkout.STRATEGY.FORCE } + ); + }) + .then(function() { + return fse.writeFile( + path.join(repository.workdir(), theirOtherFileName), + theirOtherFileContent + ); + }) + .then(function() { + return RepoUtils.addFileToIndex(repository, theirOtherFileName); + }) + .then(function(oid) { + assert.equal(oid.toString(), + "c242b53f2c9446544cf9bdac7e8ed6ce583226cb"); + + return repository.createCommit(theirBranch.name(), theirOtherSignature, + theirOtherSignature, "they made another commit", oid, [theirCommit]); + }) + .then(function(commitOid) { + assert.equal(commitOid.toString(), + "8fa0ce25a2accf464b004ddeeb63add7b816b627"); + }) + .then(function() { + return Promise.all([ + repository.getReference(ourBranchName), + repository.getReference(theirBranchName) + ]); + }) + .then(function(refs) { + assert.equal(refs.length, 2); + + return Promise.all([ + NodeGit.AnnotatedCommit.fromRef(repository, refs[0]), + NodeGit.AnnotatedCommit.fromRef(repository, refs[1]) + ]); + }) + .then(function(annotatedCommits) { + assert.equal(annotatedCommits.length, 2); + + var ourAnnotatedCommit = annotatedCommits[0]; + var theirAnnotatedCommit = annotatedCommits[1]; + + assert.equal(ourAnnotatedCommit.id().toString(), + "0d1d322b59df68bac6eea6a2a189f974cb590368"); + assert.equal(theirAnnotatedCommit.id().toString(), + "8fa0ce25a2accf464b004ddeeb63add7b816b627"); + + return repository.rebaseBranches( + ourBranchName, + theirBranchName, + null, + ourSignature, + null, + function(rebaseData) { + assert.equal(rebaseData.rewritten, null); + } + ); + }) + .then(function(commit) { + assert.equal(commit.id().toString(), + "8fa0ce25a2accf464b004ddeeb63add7b816b627"); + }); + }); + it("can rebase using the convenience method", function() { var baseFileName = "baseNewFile.txt"; var ourFileName = "ourNewFile.txt"; From 62daba3b075441b48f5fefc3b4b2438e14b31e85 Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Thu, 15 Mar 2018 13:35:18 -0700 Subject: [PATCH 15/25] Replace fse.existsSync with a catch on fse.readFile --- lib/repository.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/repository.js b/lib/repository.js index 3a94b38a9..d876b1241 100644 --- a/lib/repository.js +++ b/lib/repository.js @@ -207,17 +207,18 @@ function performRebase( /* In the case of FF merges and a beforeFinishFn, this will fail * when looking for 'rewritten' so we need to handle that case. */ - function readRebaseMetadataFile(fileName, determineExistance) { - const fullPath = path.join(repository.path(), "rebase-merge", fileName); - if (determineExistance && !fse.existsSync(fullPath)) { - return Promise.resolve(null); - } - + function readRebaseMetadataFile(fileName, continueOnError) { return fse.readFile( - fullPath, + path.join(repository.path(), "rebase-merge", fileName), { encoding: "utf8" } ) - .then(fp.trim); + .then(fp.trim) + .catch(function(err) { + if (continueOnError) { + return null; + } + throw err; + }); } function calcHeadName(input) { From 716ea86851b1970837b6eb23718ba416482c0334 Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Fri, 16 Mar 2018 12:28:15 -0700 Subject: [PATCH 16/25] Add manual template for git_commit_extract_signature This is to date the only known (by the nodegit team) use case of a double return type from libgit2. If we spot other use cases for this, we will need to revisit this decision and build in the correct templating mechanism. --- generate/input/descriptor.json | 2 +- generate/input/libgit2-supplement.json | 34 ++++ .../manual/commit/extract_signature.cc | 156 ++++++++++++++++++ 3 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 generate/templates/manual/commit/extract_signature.cc diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 54d611ac0..b90b0290b 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -523,7 +523,7 @@ "ignore": true }, "git_commit_extract_signature": { - "ignore": true + "isAsync": true }, "git_commit_id": { "return": { diff --git a/generate/input/libgit2-supplement.json b/generate/input/libgit2-supplement.json index 3e0d24fd7..a31e54f2b 100644 --- a/generate/input/libgit2-supplement.json +++ b/generate/input/libgit2-supplement.json @@ -86,6 +86,40 @@ }, "new" : { "functions": { + "git_commit_extract_signature": { + "args": [ + { + "name": "signature", + "type": "git_buf" + }, + { + "name": "signed_data", + "type": "git_buf" + }, + { + "name": "repo", + "type": "git_repository *" + }, + { + "name": "commit_id", + "type": "git_oid *" + }, + { + "name": "field", + "type": "char *" + } + ], + "type": "function", + "isManual": true, + "cFile": "generate/templates/manual/commit/extract_signature.cc", + "isAsync": true, + "isPrototypeMethod": false, + "group": "commit", + "return": { + "type": "int", + "isErrorCode": true + } + }, "git_patch_convenient_from_diff": { "args": [ { diff --git a/generate/templates/manual/commit/extract_signature.cc b/generate/templates/manual/commit/extract_signature.cc new file mode 100644 index 000000000..581eef6b8 --- /dev/null +++ b/generate/templates/manual/commit/extract_signature.cc @@ -0,0 +1,156 @@ +NAN_METHOD(GitCommit::ExtractSignature) +{ + if (info.Length() == 0 || !info[0]->IsObject()) { + return Nan::ThrowError("Repository repo is required."); + } + + if (info.Length() == 1 || (!info[1]->IsObject() && !info[1]->IsString())) { + return Nan::ThrowError("Oid commit_id is required."); + } + + if (info.Length() == 2 || (info.Length() == 3 && !info[2]->IsFunction())) { + return Nan::ThrowError("Callback is required and must be a Function."); + } + + if (info.Length() >= 4) { + if (!info[2]->IsString() && !info[2]->IsUndefined() && !info[2]->IsNull()) { + return Nan::ThrowError("String signature_field must be a string or undefined/null."); + } + + if (!info[3]->IsFunction()) { + return Nan::ThrowError("Callback is required and must be a Function."); + } + } + + ExtractSignatureBaton* baton = new ExtractSignatureBaton; + + baton->error_code = GIT_OK; + baton->error = NULL; + baton->signature = GIT_BUF_INIT_CONST(NULL, 0); + baton->signed_data = GIT_BUF_INIT_CONST(NULL, 0); + baton->repo = Nan::ObjectWrap::Unwrap(info[0]->ToObject())->GetValue(); + + // baton->commit_id + if (info[1]->IsString()) { + String::Utf8Value oidString(info[1]->ToString()); + baton->commit_id = (git_oid *)malloc(sizeof(git_oid)); + if (git_oid_fromstr(baton->commit_id, (const char *)strdup(*oidString)) != GIT_OK) { + free(baton->commit_id); + + if (giterr_last()) { + return Nan::ThrowError(giterr_last()->message); + } else { + return Nan::ThrowError("Unknown Error"); + } + } + } else { + baton->commit_id = Nan::ObjectWrap::Unwrap(info[1]->ToObject())->GetValue(); + } + + // baton->field + if (info[2]->IsString()) { + String::Utf8Value field(info[2]->ToString()); + baton->field = (char *)malloc(field.length() + 1); + memcpy((void *)baton->field, *field, field.length()); + baton->field[field.length()] = 0; + } else { + baton->field = NULL; + } + + Nan::Callback *callback; + if (info[2]->IsFunction()) { + callback = new Nan::Callback(Local::Cast(info[2])); + } else { + callback = new Nan::Callback(Local::Cast(info[3])); + } + + ExtractSignatureWorker *worker = new ExtractSignatureWorker(baton, callback); + worker->SaveToPersistent("repo", info[0]->ToObject()); + worker->SaveToPersistent("commit_id", info[1]->ToObject()); + Nan::AsyncQueueWorker(worker); + return; +} + +void GitCommit::ExtractSignatureWorker::Execute() +{ + giterr_clear(); + + { + LockMaster lockMaster( + /*asyncAction: */true, + baton->repo + ); + + baton->error_code = git_commit_extract_signature( + &baton->signature, + &baton->signed_data, + baton->repo, + baton->commit_id, + (const char *)baton->field + ); + + if (baton->error_code != GIT_OK && giterr_last() != NULL) { + baton->error = git_error_dup(giterr_last()); + } + } +} + +void GitCommit::ExtractSignatureWorker::HandleOKCallback() +{ + if (baton->error_code == GIT_OK) + { + Local result = Nan::New(); + Nan::Set( + result, + Nan::New("signature").ToLocalChecked(), + Nan::New(baton->signature.ptr, baton->signature.size).ToLocalChecked() + ); + Nan::Set( + result, + Nan::New("signedData").ToLocalChecked(), + Nan::New(baton->signed_data.ptr, baton->signed_data.size).ToLocalChecked() + ); + + Local argv[2] = { + Nan::Null(), + result + }; + callback->Call(2, argv); + } + else if (baton->error) + { + Local argv[1] = { + Nan::Error(baton->error->message) + }; + callback->Call(1, argv); + if (baton->error->message) + { + free((void *)baton->error->message); + } + + free((void *)baton->error); + } + else if (baton->error_code < 0) + { + Local err = Nan::Error("Extract Signature has thrown an error.")->ToObject(); + err->Set(Nan::New("errno").ToLocalChecked(), Nan::New(baton->error_code)); + err->Set(Nan::New("errorFunction").ToLocalChecked(), Nan::New("Commit.extractSignature").ToLocalChecked()); + Local argv[1] = { + err + }; + callback->Call(1, argv); + } + else + { + callback->Call(0, NULL); + } + + git_buf_free(&baton->signature); + git_buf_free(&baton->signed_data); + + if (baton->field != NULL) { + free((void *)baton->field); + } + + delete baton; +} From 9a89c82f3ac2569cee871836d6407cd8bbb51ef2 Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Fri, 16 Mar 2018 12:54:31 -0700 Subject: [PATCH 17/25] add gitSignature to commit prototype --- lib/commit.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/commit.js b/lib/commit.js index 73d3f62b4..232d771b0 100644 --- a/lib/commit.js +++ b/lib/commit.js @@ -4,6 +4,7 @@ var Commit = NodeGit.Commit; var LookupWrapper = NodeGit.Utils.lookupWrapper; var _amend = Commit.prototype.amend; + /** * Retrieves the commit pointed to by the oid * @async @@ -162,6 +163,23 @@ Commit.prototype.getParents = function(limit, callback) { }, callback); }; +/** + * @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. * From 15fa3980264ce8d79849a4a7197b54c79ae41374 Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Fri, 16 Mar 2018 14:04:56 -0700 Subject: [PATCH 18/25] Add tests for extractSignature --- test/tests/commit.js | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/tests/commit.js b/test/tests/commit.js index 94d357a0a..63f8d2b17 100644 --- a/test/tests/commit.js +++ b/test/tests/commit.js @@ -718,4 +718,43 @@ describe("Commit", function() { // the self-freeing signature should get freed assert.equal(startSelfFreeingCount, endSelfFreeingCount); }); + + describe("Commit's Signature", function() { + it.only("Can retrieve the gpg signature from a commit", function() { + var expectedSignedData = + "tree f4661419a6fbbe865f78644fec722c023ce4b65f\n" + + "parent 32789a79e71fbc9e04d3eff7425e1771eb595150\n" + + "author Tyler Ang-Wanek 1521227848 -0700\n" + + "committer Tyler Ang-Wanek 1521227848 -0700\n\n" + + "GPG Signed commit\n"; + + var expectedSignature = + "-----BEGIN PGP SIGNATURE-----\n\n" + + "iQEcBAABCAAGBQJarBhIAAoJEE8pfTd/81lKQA4IAL8Mu5kc4B/MX9s4XB26Ahap\n" + + "n06kCx3RQ1KHMZIRomAjCnb48WieNVuy1y+Ut0RgfCxxrJ1ZnzFG3kF2bIKwIxNI\n" + + "tYIC76iWny+mrVnb2mjKYjn/3F4c4VJGENq9ITiV1WeE4yJ8dHw2ox2D+hACzTvQ\n" + + "KVroedk8BDFJxS6DFb20To35xbAVhwBnAGRcII4Wi5PPMFpqAhGLfq3Czv95ddSz\n" + + "BHlyp27+YWSpV0Og0dqOEhsdDYaPrOBGRcoRiqjue+l5tgK/QerLFZ4aovZzpuEP\n" + + "Xx1yZfqXIiy4Bo40qScSrdnmnp/kMq/NQGR3jYU+SleFHVKNFsya9UwurMaezY0=\n" + + "=eZzi\n-----END PGP SIGNATURE-----"; + + return NodeGit.Commit.lookup( + this.repository, + "cc1401eaac4e9e77190e98a9353b305f0c6313d8" + ) + .then(function(commit) { + return commit.getSignature(); + }) + .then(function(extractSignature) { + assert.equal( + extractSignature.signature, + expectedSignature + ); + assert.equal( + extractSignature.signedData, + expectedSignedData + ); + }); + }); + }); }); From 1d9df0dac71380ac02c09ec11f67ac6207ed5347 Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Fri, 16 Mar 2018 14:37:46 -0700 Subject: [PATCH 19/25] Exposed git_config_open_ondisk --- generate/input/descriptor.json | 10 +++- test/tests/config.js | 93 ++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index 54d611ac0..3b5475f56 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -666,7 +666,15 @@ "ignore": true }, "git_config_open_ondisk": { - "ignore": true + "isAsync": true, + "return": { + "isErrorCode": true + }, + "args": { + "out": { + "isReturn": true + } + } }, "git_config_parse_bool": { "ignore": true diff --git a/test/tests/config.js b/test/tests/config.js index 3ac6fca48..b7c23809f 100644 --- a/test/tests/config.js +++ b/test/tests/config.js @@ -6,9 +6,102 @@ var exec = require("../../utils/execPromise"); describe("Config", function() { var NodeGit = require("../../"); + var Repository = NodeGit.Repository; + var Config = NodeGit.Config; var reposPath = local("../repos/workdir"); + describe("openOnDisk", function() { + var configPath = path.join(reposPath, ".git/config"); + + it("opens the same config as the repo", function() { + var repo; + var onDiskConfig; + return Repository.open(reposPath) + .then(function(_repo) { + repo = _repo; + return Config.openOndisk(configPath); + }) + .then(function(config) { + onDiskConfig = config; + return repo.config(); + }) + .then(function(repoConfig) { + return Promise.all([ + onDiskConfig.getString("core.filemode"), + onDiskConfig.getString("core.bare"), + onDiskConfig.getString("core.ignorecase"), + repoConfig.getString("core.filemode"), + repoConfig.getString("core.bare"), + repoConfig.getString("core.ignorecase") + ]); + }) + .then(function(results) { + var onDiskFileMode = results[0]; + var onDiskBare = results[1]; + var onDiskIgnorecase = results[2]; + var repoFileMode = results[3]; + var repoBare = results[4]; + var repoIgnorecase = results[5]; + + assert.equal(onDiskFileMode, repoFileMode); + assert.equal(onDiskBare, repoBare); + assert.equal(onDiskIgnorecase, repoIgnorecase); + }); + }); + + it("opens the config and can change a value", function() { + var repo; + var onDiskConfig; + var repoConfig; + var originalFileMode; + return Repository.open(reposPath) + .then(function(_repo) { + repo = _repo; + return Config.openOndisk(configPath); + }) + .then(function(config) { + onDiskConfig = config; + return repo.config(); + }) + .then(function(_repoConfig) { + repoConfig = _repoConfig; + return Promise.all([ + onDiskConfig.getString("core.filemode"), + repoConfig.getString("core.filemode") + ]); + }) + .then(function(results) { + var onDiskFileMode = results[0]; + var repoFileMode = results[1]; + + assert.equal(onDiskFileMode, repoFileMode); + originalFileMode = onDiskFileMode; + var oppositeFileMode = onDiskFileMode === "true" ? "false" : "true"; + + return onDiskConfig.setString( + "core.filemode", + oppositeFileMode + ); + }) + .then(function() { + return Config.openOndisk(configPath); + }) + .then(function(config) { + return Promise.all([ + config.getString("core.filemode"), + repoConfig.getString("core.filemode") + ]); + }) + .then(function(results) { + var onDiskFileMode = results[0]; + var repoFileMode = results[1]; + assert.notEqual(onDiskFileMode, originalFileMode); + assert.equal(onDiskFileMode, repoFileMode); + }); + }); + }); + it("can get and set a global value", function() { var savedUserName; From 070234935f20a062997898bfe7fe8474bb195e60 Mon Sep 17 00:00:00 2001 From: dabutvin Date: Fri, 16 Mar 2018 18:31:52 -0700 Subject: [PATCH 20/25] removes 'only' from test --- test/tests/commit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/commit.js b/test/tests/commit.js index 63f8d2b17..181a1461b 100644 --- a/test/tests/commit.js +++ b/test/tests/commit.js @@ -720,7 +720,7 @@ describe("Commit", function() { }); describe("Commit's Signature", function() { - it.only("Can retrieve the gpg signature from a commit", function() { + it("Can retrieve the gpg signature from a commit", function() { var expectedSignedData = "tree f4661419a6fbbe865f78644fec722c023ce4b65f\n" + "parent 32789a79e71fbc9e04d3eff7425e1771eb595150\n" + From f25988c6d2063010ff4d284f37c6a65b50d88b7d Mon Sep 17 00:00:00 2001 From: Croydon Date: Sat, 17 Mar 2018 15:08:00 +0100 Subject: [PATCH 21/25] Travis: Only deploy documentation on tags --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8daee73e..77d182cb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ before_install: - export npm_config_clang=1 - export JOBS=4 - - if [ -z "$TRAVIS_TAG" ] && [ $EXTENDED_TESTING == "true" ]; then + - if [ -z "$TRAVIS_TAG" ] && [ "$EXTENDED_TESTING" == "true" ]; then export GYP_DEFINES="coverage=1 use_obsolete_asm=true"; export CC=/usr/bin/gcc-4.9; export CXX=/usr/bin/g++-4.9; @@ -88,7 +88,7 @@ before_script: - git config --global user.email johndoe@example.com script: - if [ -z "$TRAVIS_TAG" ] && [ $EXTENDED_TESTING == "true" ]; then + if [ -z "$TRAVIS_TAG" ] && [ "$EXTENDED_TESTING" == "true" ]; then travis_retry npm test && npm run cov && npm run coveralls; else travis_retry npm test; @@ -103,7 +103,7 @@ after_success: node-pre-gyp publish --target_arch=$TARGET_ARCH; fi - - if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_PULL_REQUEST == "false" ] && [ $DEPLOY_DOCUMENTATION == "true" ]; then + - if [ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ -n "$TRAVIS_TAG" ] && [ "$DEPLOY_DOCUMENTATION" == "true" ]; then .travis/deploy-docs.sh; fi From 9cd3c072bdab2b8e667ab91159ca5b1df2cc8445 Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Mon, 19 Mar 2018 09:38:24 -0700 Subject: [PATCH 22/25] add cleanup to unit test --- test/tests/config.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/tests/config.js b/test/tests/config.js index b7c23809f..f94f97f76 100644 --- a/test/tests/config.js +++ b/test/tests/config.js @@ -98,6 +98,13 @@ describe("Config", function() { var repoFileMode = results[1]; assert.notEqual(onDiskFileMode, originalFileMode); assert.equal(onDiskFileMode, repoFileMode); + }) + .then(function() { + // cleanup + return onDiskConfig.setString( + "core.filemode", + originalFileMode + ); }); }); }); From e7254072cc1287a46a58d133bddf79d62ce4d76b Mon Sep 17 00:00:00 2001 From: Carson Howard Date: Mon, 19 Mar 2018 10:14:59 -0700 Subject: [PATCH 23/25] Fix config casing --- test/tests/config.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/tests/config.js b/test/tests/config.js index f94f97f76..218aad144 100644 --- a/test/tests/config.js +++ b/test/tests/config.js @@ -30,23 +30,18 @@ describe("Config", function() { return Promise.all([ onDiskConfig.getString("core.filemode"), onDiskConfig.getString("core.bare"), - onDiskConfig.getString("core.ignorecase"), repoConfig.getString("core.filemode"), - repoConfig.getString("core.bare"), - repoConfig.getString("core.ignorecase") + repoConfig.getString("core.bare") ]); }) .then(function(results) { var onDiskFileMode = results[0]; var onDiskBare = results[1]; - var onDiskIgnorecase = results[2]; - var repoFileMode = results[3]; - var repoBare = results[4]; - var repoIgnorecase = results[5]; + var repoFileMode = results[2]; + var repoBare = results[3]; assert.equal(onDiskFileMode, repoFileMode); assert.equal(onDiskBare, repoBare); - assert.equal(onDiskIgnorecase, repoIgnorecase); }); }); From 3cf1b15999295b27c8443d91d25cd34175db66d6 Mon Sep 17 00:00:00 2001 From: Jake Krammer Date: Mon, 19 Mar 2018 12:57:35 -0700 Subject: [PATCH 24/25] Expose git_config functions --- generate/input/descriptor.json | 44 ++++++++++++++++++++++++++++++---- test/tests/config.js | 20 ++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/generate/input/descriptor.json b/generate/input/descriptor.json index b90b0290b..8089d1bdb 100644 --- a/generate/input/descriptor.json +++ b/generate/input/descriptor.json @@ -576,13 +576,40 @@ "ignore": true }, "git_config_find_global": { - "ignore": true + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true + } + }, + "return": { + "isErrorCode": true + } }, "git_config_find_system": { - "ignore": true + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true + } + }, + "return": { + "isErrorCode": true + } }, "git_config_find_xdg": { - "ignore": true + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true + } + }, + "return": { + "isErrorCode": true + } }, "git_config_foreach": { "ignore": true @@ -627,7 +654,16 @@ } }, "git_config_get_path": { - "ignore": true + "isAsync": true, + "args": { + "out": { + "isReturn": true, + "shouldAlloc": true + } + }, + "return": { + "isErrorCode": true + } }, "git_config_iterator_free": { "ignore": true diff --git a/test/tests/config.js b/test/tests/config.js index 3ac6fca48..469bcf672 100644 --- a/test/tests/config.js +++ b/test/tests/config.js @@ -92,4 +92,24 @@ describe("Config", function() { }); }); }); + + describe("getPath", function() { + it("can get path for a given config", function() { + return NodeGit.Repository.open(reposPath) + .then(function(repo) { + return repo.config(); + }) + .then(function(config) { + return Promise.all([ + config.getPath("core.filemode"), + config.getString("core.filemode") + ]); + }) + .then(function(results) { + var localFilemode = results[0]; + var repoFilemode = results[1]; + assert.equal(localFilemode, repoFilemode); + }); + }); + }); }); From a8b2604b8e42f6c9a17a37b949c94349ac252205 Mon Sep 17 00:00:00 2001 From: Tyler Ang-Wanek Date: Mon, 19 Mar 2018 16:00:57 -0700 Subject: [PATCH 25/25] Bump to 0.21.2 --- CHANGELOG.md | 29 ++++++++++++++++++++++++++++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa0743e03..5b21f4837 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Change Log +## v0.21.2v0.21.1 [(2018-03-05)](https://github.com/nodegit/nodegit/releases/tag/v0.21.1) [Full Changelog](https://github.com/nodegit/nodegit/compare/v0.21.0...v0.21.1) @@ -14,7 +41,7 @@ [Full Changelog](https://github.com/nodegit/nodegit/compare/v0.20.3...v0.21.0) -### Summary of changes to NodeGit: +#### Summary of changes to NodeGit: - [Generate default options for Revert.revert to prevent an exception #1404](https://github.com/nodegit/nodegit/pull/1404) - [fix issue with re-require()'ing native modules #1354](https://github.com/nodegit/nodegit/pull/1354) - [Expose JavaScript function name in a rejected promise #1393](https://github.com/nodegit/nodegit/pull/1393) diff --git a/package-lock.json b/package-lock.json index cda103de2..6d7b069eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "nodegit", - "version": "0.21.1", + "version": "0.21.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 507ac1e63..1062b4010 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nodegit", "description": "Node.js libgit2 asynchronous native bindings", - "version": "0.21.1", + "version": "0.21.2", "homepage": "http://nodegit.org", "keywords": [ "libgit2",