FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make libgit2 an actual submodule by johnhaley81 · Pull Request #1017 · nodegit/nodegit · GitHub

Repository navigation

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

Filter by extension

Filter by extension .c  (469) .cmake  (6) .def  (2) .docurium  (1) .embed  (1) .git-authors  (1) .h  (253) .idx  (7) .in  (1) .index  (3) .js  (16) .md  (14) .pack  (7) .py  (1) .rc  (1) .renamed  (1) .sh  (6) .supp  (1) .txt  (43) .yml  (2) No extension  (2149) dotfile  (15) All 22 file types selected
Deleted files Viewed files
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 4 additions & 0 deletions .gitmodules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "vendor/libgit2"]
path = vendor/libgit2
[submodule "vendor/libgit2"]
url = https://github.com/nodegit/libgit2.git
31 changes: 23 additions & 8 deletions generate/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
var generateJson = require("./scripts/generateJson");
var generateNativeCode = require("./scripts/generateNativeCode");
var generateMissingTests = require("./scripts/generateMissingTests");
var submoduleStatus = require("../lifecycleScripts/submodules/getStatus");

module.exports = function generate() {
return new Promise(function(resolve, reject) {
try {
return submoduleStatus()
.then(function(statuses) {
var dirtySubmodules = statuses
.filter(function(status) {
return status.onNewCommit
|| status.needsInitialization
|| status.workDirDirty;
});

if (dirtySubmodules.length) {
console.log("WARNING - Some submodules are out-of-sync");
dirtySubmodules.forEach(function(submodule) {
console.log("\t" + submodule.name);
});
}
})
.then(function() {
generateJson();
generateNativeCode();
generateMissingTests();
resolve();
}
catch(e) {
reject(e);
}
});
})
.catch(function(e) {
console.log("ERROR - Could not generate native code");
console.log(e);
});
}

if (require.main === module) {
Expand Down
5 changes: 1 addition & 4 deletions generate/scripts/generateNativeCode.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const path = require("path");
const promisify = require("promisify-node");
const fse = promisify(require("fs-extra"));
const exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});

const exec = require('../../utils/execPromise');
const utils = require("./utils");

module.exports = function generateNativeCode() {
Expand Down
8 changes: 2 additions & 6 deletions lifecycleScripts/install.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
var promisify = require("promisify-node");
var path = require("path");
var fs = require("fs");
var cp = require("child_process");
var prepareForBuild = require("./prepareForBuild");

var exec = promisify(function(command, opts, callback) {
return cp.exec(command, opts, callback);
});
var exec = require("../utils/execPromise");

var fromRegistry;

try {
fs.statSync(path.join(__dirname, "..", "include"));
fs.statSync(path.join(__dirname, "..", "src"));
Expand Down Expand Up @@ -124,7 +121,6 @@ function build() {
return arg;
});

console.log(args);
return new Promise(function(resolve, reject) {
var child = cp.spawn(cmd, args, opts);
child.on("close", function(code) {
Expand Down
8 changes: 6 additions & 2 deletions lifecycleScripts/prepareForBuild.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ var path = require("path");

var local = path.join.bind(path, __dirname);

var submodules = require(local("submodules"));
var configure = require(local("configureLibssh2"));
var generate = require(local("../generate"));

module.exports = function prepareForBuild() {

return new Promise(function(resolve, reject) {
cp.exec("npm install --ignore-scripts", function(err, stdout, stderr) {
if (err) {
Expand All @@ -19,7 +19,11 @@ module.exports = function prepareForBuild() {
console.info(stdout);
}
});
}).then(function() {
})
.then(function() {
return submodules();
})
.then(function() {
return Promise.all([
configure(),
generate()
Expand Down
37 changes: 37 additions & 0 deletions lifecycleScripts/submodules/getStatus.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
var path = require("path");
var rootDir = path.join(__dirname, "../..");
var exec = require(path.join(rootDir, "./utils/execPromise"));

module.exports = function getStatus() {
return exec("git submodule status", { cwd: rootDir})
.then(function(stdout) {
function getStatusPromiseFromLine(line) {
var lineSections = line.trim().split(" ");
var onNewCommit = !!~lineSections[0].indexOf("+");
var needsInitialization = !!~lineSections[0].indexOf("-");
var commitOid = lineSections[0].replace("+", "").replace("-", "");
var name = lineSections[1];

return exec("git status", { cwd: path.join(rootDir, name)})
.then(function(workDirStatus) {
return {
commitOid: commitOid,
onNewCommit: onNewCommit,
name: name,
needsInitialization: needsInitialization,
workDirDirty: !~workDirStatus
.trim()
.split("\n")
.pop()
.indexOf("nothing to commit")
};
});
}

return Promise.all(stdout
.trim()
.split("\n")
.map(getStatusPromiseFromLine)
);
});
};
74 changes: 74 additions & 0 deletions lifecycleScripts/submodules/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
var path = require("path");
var rootDir = path.join(__dirname, "../..");

var gitExecutableLocation = require(
path.join(rootDir, "./utils/gitExecutableLocation")
);
var submoduleStatus = require("./getStatus");

var exec = require(path.join(rootDir, "./utils/execPromise"));

module.exports = function submodules() {
return gitExecutableLocation()
.catch(function() {
console.log("ERROR - Compilation of NodeGit requires git CLI to be " +
"installed and on the path");

throw new Error("git CLI is not installed or not on the path");
})
.then(function() {
return submoduleStatus();
})
.then(function(statuses) {
function printSubmodule(submoduleName) {
console.log("\t" + submoduleName);
}

var dirtySubmodules = statuses
.filter(function(status) {
return status.workDirDirty && !status.needsInitialization;
})
.map(function(dirtySubmodule) {
return dirtySubmodule.name;
});

if (dirtySubmodules.length) {
console.log(
"ERROR - The following submodules have uncommited changes:"
);
dirtySubmodules.forEach(printSubmodule);
console.log(
"\nThey must either be committed or discarded before we build"
);

throw new Error("Dirty Submodules: " + dirtySubmodules.join(" "));
}

var outOfSyncSubmodules = statuses
.filter(function(status) {
return status.onNewCommit && !status.needsInitialization;
})
.map(function(outOfSyncSubmodule) {
return outOfSyncSubmodule.name;
});

if (outOfSyncSubmodules.length) {
console.log(
"WARNING - The following submodules are pointing to an new commit:"
);
outOfSyncSubmodules.forEach(printSubmodule);
console.log("\nThey will not be updated.");
}

return Promise.all(statuses
.filter(function(status) {
return !status.onNewCommit;
})
.map(function(submoduleToUpdate) {
return exec(
"git submodule update --init --recursive " + submoduleToUpdate.name
);
})
);
});
};
6 changes: 1 addition & 5 deletions test/runner.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var promisify = require("promisify-node");
var fse = promisify("fs-extra");
var path = require("path");
var local = path.join.bind(path, __dirname);
var exec = require('../utils/execPromise');

var NodeGit = require('..');

Expand All @@ -13,11 +14,6 @@ if(process.env.NODEGIT_TEST_THREADSAFETY) {
NodeGit.setThreadSafetyStatus(NodeGit.THREAD_SAFETY.ENABLED_FOR_ASYNC_ONLY);
}

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});

var workdirPath = local("repos/workdir");

before(function() {
Expand Down
5 changes: 1 addition & 4 deletions test/tests/commit.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ var leakTest = require("../utils/leak_test");

var local = path.join.bind(path, __dirname);

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Commit", function() {
var NodeGit = require("../../");
Expand Down
6 changes: 1 addition & 5 deletions test/tests/config.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
var promisify = require("promisify-node");

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Config", function() {
var NodeGit = require("../../");
Expand Down
6 changes: 1 addition & 5 deletions test/tests/refs.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var assert = require("assert");
var path = require("path");
var promisify = require("promisify-node");
var local = path.join.bind(path, __dirname);

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Reference", function() {
var NodeGit = require("../../");
Expand Down
6 changes: 1 addition & 5 deletions test/tests/signature.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var assert = require("assert");
var path = require("path");
var local = path.join.bind(path, __dirname);
var promisify = require("promisify-node");

// Have to wrap exec, since it has a weird callback signature.
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Signature", function() {
var NodeGit = require("../../");
Expand Down
4 changes: 1 addition & 3 deletions test/tests/stage.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ var path = require("path");
var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));

var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Stage", function() {
var RepoUtils = require("../utils/repository_setup");
Expand Down
4 changes: 1 addition & 3 deletions test/tests/status.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ var path = require("path");
var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));
var local = path.join.bind(path, __dirname);
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("Status", function() {
var NodeGit = require("../../");
Expand Down
4 changes: 1 addition & 3 deletions test/tests/status_list.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ var path = require("path");
var promisify = require("promisify-node");
var fse = promisify(require("fs-extra"));
var local = path.join.bind(path, __dirname);
var exec = promisify(function(command, opts, callback) {
return require("child_process").exec(command, opts, callback);
});
var exec = require("../../utils/execPromise");

describe("StatusList", function() {
var NodeGit = require("../../");
Expand Down
6 changes: 6 additions & 0 deletions utils/execPromise.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var promisify = require("promisify-node");
var cp = require('child_process');

module.exports = promisify(function(command, opts, callback) {
return cp.exec(command, opts, callback);
});
23 changes: 23 additions & 0 deletions utils/gitExecutableLocation.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var cp = require("child_process");

module.exports = function gitExecutableLocation() {
return new Promise(function(resolve, reject) {
var cmd;

if (process.platform === "win32") {
cmd = "where git";
}
else {
cmd = "which git";
}

cp.exec(cmd, function(err, stdout, stderr) {
if (err) {
reject(err, stderr);
}
else {
resolve(stdout);
}
});
});
};
1 change: 1 addition & 0 deletions vendor/libgit2
Show comments Open in desktop
Submodule libgit2 added at 211e11
24 changes: 0 additions & 24 deletions vendor/libgit2/.HEADER

This file was deleted.

Loading

Back | FazBrowse Home | New Git URL