Skip to content

Commit 829d0b9

Browse files
committed
Merge pull request nodegit#310 from nodegit/fix-publishing
Appveyor seems to be randomly passing and failing this, with no real reason, so we've decided to merge this.
2 parents ca1e873 + bf20af5 commit 829d0b9

File tree

9 files changed

+153
-64
lines changed

9 files changed

+153
-64
lines changed

.npmignore

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
/doc/
1+
/build/
22
/example/
3-
/node_modules/
3+
/generate/
44
/test/
5+
/vendor/libgit2/
6+
/vendor/libssh2/
7+
/vendor/http_parser/
8+
/vendor/Release/
9+
10+
.astylerc
11+
.editorconfig
12+
.gitignore
13+
.gitmodules
14+
.jshintrc
15+
.travis.yml
16+
.appveyor.yml
17+
18+
*.vcxproj
19+
*.filters
20+
*.sln
21+
*.log
22+
*.md

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ before_script:
2323
- chmod 600 ~/.ssh/id_rsa*
2424
- eval `ssh-agent -s`
2525
- ssh-add ~/.ssh/id_rsa
26+
- git config --global user.name "John Doe"
27+
- git config --global user.email johndoe@example.com
2628
git:
2729
depth: 1
2830
branches:
@@ -35,3 +37,9 @@ script: npm test
3537
notifications:
3638
slack:
3739
secure: KglNSqZiid9YudCwkPFDh+sZfW5BwFlM70y67E4peHwwlbbV1sSBPHcs74ZHP/lqgEZ4hMv4N2NI58oYFD5/1a+tKIQP1TkdIMuq4j2LXheuirA2HDcydOVrsC8kRx5XFGKdVRg/uyX2dlRHcOWFhxrS6yc6IxtxYWlRTD2SmEc=
40+
webhooks:
41+
urls:
42+
- https://webhooks.gitter.im/e/cbafdb27ad32ba746a73
43+
on_success: always # options: [always|never|change] default: always
44+
on_failure: always # options: [always|never|change] default: always
45+
on_start: false # default: false

appveyor.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ clone_folder: c:\projects\nodegit
1414
# fix lineendings in Windows
1515
init:
1616
- git config --global core.autocrlf input
17+
- git config --global user.name "John Doe"
18+
- git config --global user.email johndoe@example.com
1719

1820
# what combinations to test
1921
environment:
@@ -39,3 +41,13 @@ test_script:
3941
- cmd: npm test
4042

4143
build: off
44+
45+
notifications:
46+
- provider: Slack
47+
auth_token:
48+
secure: ZsaMCvRMfDZhNsiUvZtvszXXF3z4pLIGJmAj5MuDaa40JvmMC6wnBWIR+LHJuJPM
49+
channel: nodegit
50+
51+
branches:
52+
only:
53+
- master

install.js

Lines changed: 82 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function systemPath(parts) {
4848
}
4949

5050
// Will be used near the end to configure `node-gyp`.
51-
var pythonPath = '/usr/bin/python';
51+
var pythonPath = "";
5252

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

@@ -58,12 +58,7 @@ var paths = envOverride({
5858
libgit2: local("vendor/libgit2/"),
5959
libssh2: local("vendor/libssh2/"),
6060
http_parser: local("vendor/http_parser/"),
61-
sys: {
62-
include: local("include/sys/"),
63-
src: local("src/sys/"),
64-
build: local("build/Release/obj.target/src/sys/")
65-
},
66-
release: local("build/Release/")
61+
release: local("build/Release/"),
6762
});
6863

6964
// Load the package.json.
@@ -76,8 +71,7 @@ if (NODE_VERSION === 0.1) {
7671
fse.ensureDir(path.resolve(__dirname, paths.release))
7772
.then(detectNodeWebkit.call(null, __dirname))
7873
.then(fetch)
79-
.then(finish, compile)
80-
.done()
74+
.then(finish, compile);
8175

8276
function fetch() {
8377
console.info("[nodegit] Fetching binary from S3.");
@@ -104,83 +98,103 @@ function compile(err) {
10498

10599
console.info("[nodegit] Determining dependencies.");
106100

107-
return python()
108-
.then(getVendorLib("libgit2", "https://github.com/libgit2/libgit2/tarball/" + pkg.libgit2.sha))
109-
.then(getVendorLib("libssh2", pkg.libssh2.url))
110-
.then(getVendorLib("http_parser", pkg.http_parser.url))
111-
.then(buildNative)
112-
.then(finish, fail);
113-
101+
return Promise.all([
102+
python(),
103+
getVendorLib("libgit2", "https://github.com/libgit2/libgit2/tarball/" + pkg.libgit2.sha),
104+
getVendorLib("libssh2", pkg.libssh2.url),
105+
getVendorLib("http_parser", pkg.http_parser.url),
106+
guardGenerated()
107+
])
108+
.then(buildNative)
109+
.then(finish, fail);
114110
}
115111

116112
function python() {
117-
return exec("which python2")
113+
var pathFinderCommand = process.platform === "win32" ? "where" : "which";
114+
115+
return exec(pathFinderCommand + " python2")
118116
.then(function(which){
119117
return which;
120118
}, function(err) {
121119
return null;
122120
})
123121
.then(function(path) {
124-
return path || exec("which python");
122+
return path || exec(pathFinderCommand + " python");
125123
})
126-
.then(function(which) {
127-
return which;
124+
.then(function(path) {
125+
return path;
128126
}, function(err) {
129127
return null;
130128
})
131129
.then(function(path) {
132-
pythonPath = path.trim();
133-
if (!pythonPath) {
130+
if (!path) {
134131
throw new Error("Python is required to build libgit2.");
135132
}
133+
return path.trim();
134+
}, function(err) {
135+
throw new Error("Error finding python.");
136136
})
137-
.then(function() {
138-
return exec(pythonPath + " -V 2>&1");
137+
.then(function(path) {
138+
pythonPath = path;
139+
return exec(path + " -V 2>&1");
139140
})
140141
.then(function(version) {
141-
if (version[1].indexOf("Python 3") === 0) {
142+
if (version.trim().indexOf("Python 3") === 0) {
142143
throw new Error("Incorrect version of Python, gyp requires < 3.");
143144
}
144145
});
145146
}
146147

147148
function getVendorLib(name, url) {
148-
return function() {
149-
var version = pkg[name].sha || pkg[name].version;
150-
console.info("[nodegit] Detecting vendor/" + name + ".");
151-
if (fse.existsSync(paths[name] + version)) {
152-
console.info("[nodegit] vendor/" + name + " already exists.");
153-
return new Promise(function(resolve, reject) {resolve() });
154-
}
155-
else {
156-
console.info("[nodegit] Removing outdated vendor/" + name + ".");
157-
return fse.remove(paths[name])
158-
.then(function() {
159-
return new Promise(function (resolve, reject) {
160-
161-
console.info("[nodegit] Fetching vendor/" + name + ".");
149+
var version = pkg[name].sha || pkg[name].version;
150+
console.info("[nodegit] Detecting vendor/" + name + ".");
151+
if (fse.existsSync(paths[name] + version)) {
152+
console.info("[nodegit] vendor/" + name + " already exists.");
153+
return Promise.resolve();
154+
}
155+
else {
156+
console.info("[nodegit] Removing outdated vendor/" + name + ".");
157+
return fse.remove(paths[name])
158+
.then(function() {
159+
return new Promise(function (resolve, reject) {
162160

163-
var extract = tar.Extract({
164-
path: paths[name],
165-
strip: true
166-
});
161+
console.info("[nodegit] Fetching vendor/" + name + ".");
167162

168-
request.get(url).pipe(zlib.createUnzip()).pipe(extract)
169-
.on("error", reject)
170-
.on("end", resolve);
163+
var extract = tar.Extract({
164+
path: paths[name],
165+
strip: true
171166
});
172-
}).then(function() {
173-
return fse.writeFile(paths[name] + version, "");
174-
}).then(function() {
175-
if ((name == "libssh2") && (process.platform !== "win32")) {
176167

177-
return exec(paths[name] + "configure", {cwd: paths[name]});
178-
}
168+
request.get(url).pipe(zlib.createUnzip()).pipe(extract)
169+
.on("error", reject)
170+
.on("end", resolve);
179171
});
180-
}
172+
}).then(function() {
173+
return fse.writeFile(paths[name] + version, "");
174+
}).then(function() {
175+
if ((name == "libssh2") && (process.platform !== "win32")) {
176+
return exec(paths[name] + "configure", {cwd: paths[name]});
177+
}
178+
});
181179
}
182180
}
183181

182+
function guardGenerated() {
183+
return Promise.all([
184+
fse.stat(path.resolve(__dirname, "src/")),
185+
fse.stat(path.resolve(__dirname, "include/"))
186+
]).then(function() {
187+
return Promise.resolve();
188+
}, function() {
189+
console.info("[nodegit] C++ files not found, generating now.");
190+
console.info("[nodegit] Installing all devDependencies");
191+
return exec("npm install --ignore-scripts --dont-prepublish")
192+
.then(function() {
193+
return exec("node generate");
194+
});
195+
});
196+
}
197+
184198
function buildNative() {
185199
return exec("cd " + __dirname).then(function() {
186200
if (nodeWebkit) {
@@ -221,7 +235,21 @@ function detectNodeWebkit(directory) {
221235

222236
function finish() {
223237
console.info("[nodegit] Completed installation successfully.");
224-
return Promise.resolve().done();
238+
if (!buildOnly) {
239+
console.info("[nodegit] Cleaning up");
240+
return Promise.all([
241+
fse.remove(path.resolve(__dirname, "src")),
242+
fse.remove(path.resolve(__dirname, "include")),
243+
fse.remove(path.resolve(__dirname, "generate/output")),
244+
fse.remove(path.resolve(__dirname, paths.libgit2)),
245+
fse.remove(path.resolve(__dirname, paths.libssh2)),
246+
fse.remove(path.resolve(__dirname, paths.http_parser))
247+
// exec("npm prune --production")
248+
]).done();
249+
}
250+
else {
251+
return Promise.resolve().done();
252+
}
225253
}
226254

227255
function fail(message) {

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,8 @@
6060
"node-pre-gyp"
6161
],
6262
"dependencies": {
63-
"combyne": "~0.6.2",
6463
"find-parent-dir": "^0.3.0",
6564
"fs-extra": "^0.12.0",
66-
"istanbul": "~0.3.2",
67-
"js-beautify": "^1.5.4",
68-
"jshint": "~2.5.6",
69-
"lodash": "^2.4.1",
70-
"mocha": "~1.21.4",
7165
"nan": "~1.3.0",
7266
"node-gyp": "~1.0.2",
7367
"node-pre-gyp": "~0.5.27",
@@ -77,6 +71,14 @@
7771
"request": "~2.45.0",
7872
"tar": "~1.0.1"
7973
},
74+
"devDependencies": {
75+
"mocha": "~1.21.4",
76+
"combyne": "~0.6.2",
77+
"istanbul": "~0.3.2",
78+
"js-beautify": "^1.5.4",
79+
"jshint": "~2.5.6",
80+
"lodash": "^2.4.1"
81+
},
8082
"binary": {
8183
"module_name": "nodegit",
8284
"module_path": "./build/Release/",
@@ -91,8 +93,9 @@
9193
"generateJson": "node generate/scripts/generateJson",
9294
"generateNativeCode": "node generate/scripts/generateNativeCode",
9395
"generateMissingTests": "node generate/scripts/generateMissingTests",
96+
"prepublish": "node prepublish",
9497
"publish": "node-pre-gyp package && node-pre-gyp publish",
95-
"install": "node generate && node install",
98+
"install": "node install",
9699
"recompile": "BUILD_ONLY=true npm install",
97100
"rebuild": "BUILD_ONLY=true node generate && node-gyp configure build"
98101
}

prepublish.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var exec = require('child_process').exec;
2+
try {
3+
require("./build/Release/nodegit");
4+
console.info("[nodegit] Nothing to do.")
5+
}
6+
catch (e) {
7+
exec("node generate");
8+
}

test/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ var args = [
1010

1111
require("child_process").fork("../node_modules/istanbul/lib/cli.js", args, {
1212
cwd: __dirname
13+
}).on("close", function(code) {
14+
process.exit(code);
1315
});

test/tests/merge.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ describe("Merge", function() {
213213
});
214214
})
215215
.then(function() {
216-
return repository.mergeBranches(ourBranchName, theirBranchName);
216+
return repository.mergeBranches(
217+
ourBranchName,
218+
theirBranchName,
219+
ourSignature);
217220
})
218221
.then(function(oid) {
219222
assert.equal(oid.toString(),

test/tests/repository.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ describe("Repository", function() {
77

88
var Repository = require("../../lib/repository");
99
var Index = require("../../lib/index");
10+
var Signature = require("../../lib/signature");
1011

1112
before(function() {
1213
var test = this;
@@ -58,4 +59,10 @@ describe("Repository", function() {
5859
assert.equal(branch.shorthand(), "master");
5960
});
6061
});
62+
63+
it("can get the default signature", function() {
64+
var sig = this.repository.defaultSignature();
65+
66+
assert(sig instanceof Signature);
67+
});
6168
});

0 commit comments

Comments
 (0)