moved away from multiple repos, to a single bare repo which we pull the resp-spec out of.

This commit is contained in:
Spencer Alger
2014-04-29 19:17:29 -07:00
parent 3d2b080049
commit 17e95f836f
3 changed files with 48 additions and 28 deletions

2
.gitignore vendored
View File

@ -9,7 +9,7 @@ test/integration/yaml_suite/log
## generated files ## generated files
test/integration/yaml_suite/yaml_tests*.json test/integration/yaml_suite/yaml_tests*.json
test/integration/yaml_suite/index*.js test/integration/yaml_suite/index*.js
src/elasticsearch*/ src/_elasticsearch*
src/bower*/ src/bower*/
junit-*.xml junit-*.xml
elasticsearch*.log elasticsearch*.log

View File

@ -42,4 +42,8 @@ function _spawn(cmd, args, opts, cb) {
} }
return cp; return cp;
} }
_spawn.exec = function (cmd, cb) {
return _spawn('/bin/sh', ['-c', cmd], cb);
};

View File

@ -1,3 +1,4 @@
/*jshint curly: false */
var async = require('async'); var async = require('async');
var fs = require('fs'); var fs = require('fs');
var spawn = require('../_spawn'); var spawn = require('../_spawn');
@ -48,6 +49,10 @@ if (argv.branch) {
branches = utils.branches; branches = utils.branches;
} }
var sourceDir = fromRoot('src/_elasticsearch_');
function storeDir(branch) {
return fromRoot('src/_elasticsearch_' + _.snakeCase(branch));
}
function isDirectory(dir) { function isDirectory(dir) {
var stat; var stat;
@ -55,47 +60,55 @@ function isDirectory(dir) {
return (stat && stat.isDirectory()); return (stat && stat.isDirectory());
} }
function storeDir(branch) {
return fromRoot('src/elasticsearch_' + _.snakeCase(branch));
}
function spawnStep(cmd, args, cwd) { function spawnStep(cmd, args, cwd) {
return function (done) { return function (done) {
spawn(cmd, args, { spawn(cmd, args, {
verbose: argv.versbose, verbose: argv.verbose,
cwd: cwd cwd: cwd
}, function (status) { }, function (status) {
done(status ? new Error('Non-zero exit code: %d', status) : void 0); done(status ? new Error('Non-zero exit code: ' + status) : void 0);
}); });
}; };
} }
function checkoutStep(branch) { function execStep(cmd, cwd) {
return function (done) { return function (done) {
var dir = storeDir(branch); spawn.exec(cmd, {
verbose: argv.verbose,
if (isDirectory(dir)) { cwd: cwd
return done(); }, function (status) {
} done(status ? new Error('Non-zero exit code: ' + status) : void 0);
});
spawnStep('git', [
'clone', '--depth', '50', '--branch', branch, '--', esUrl, dir
], root)(done);
}; };
} }
function updateStep(branch) { function cloneStep() {
return function (done) { return function (done) {
if (!argv.update) { if (isDirectory(sourceDir)) return done();
return done(); spawnStep('git', ['clone', '--depth', '1', '--mirror', esUrl, sourceDir], root)(done);
} };
}
function fetchBranchStep(branch) {
return spawnStep('git', ['fetch', '--depth', '1', 'origin', branch], sourceDir);
}
function removePrevArchive(branch) {
return function (done) {
var dir = storeDir(branch); var dir = storeDir(branch);
if (!isDirectory(dir)) return done();
else spawnStep('rm', ['-rf', dir], root)(done);
};
}
function createArchive(branch) {
return function (done) {
var dir = storeDir(branch);
if (isDirectory(dir)) return done();
async.series([ async.series([
spawnStep('git', ['fetch', 'origin', branch], dir), spawnStep('mkdir', [dir], root),
spawnStep('git', ['reset', '--hard', 'origin/' + branch], dir), execStep('git archive --format tar ' + branch + ' rest-api-spec | tar -x -C ' + dir, sourceDir)
spawnStep('git', ['clean', '-fdx'], dir)
], done); ], done);
}; };
} }
@ -109,11 +122,14 @@ function generateStep(branch) {
}; };
} }
var steps = []; var steps = [
cloneStep()
];
branches.forEach(function (branch) { branches.forEach(function (branch) {
if (argv.update) steps.push(removePrevArchive(branch));
steps.push( steps.push(
checkoutStep(branch), fetchBranchStep(branch),
updateStep(branch), createArchive(branch),
generateStep(branch) generateStep(branch)
); );
}); });