Place a git_hash within the archive, and use it in place of git rev-parse

This commit is contained in:
Matt Godbolt
2017-10-25 22:25:34 -05:00
parent f4f400adcf
commit c82fa1db32
2 changed files with 10 additions and 3 deletions

View File

@@ -89,6 +89,7 @@ dist: prereqs
rm -rf out/dist
$(NODE) ./node_modules/requirejs/bin/r.js -o app.build.js
# Move all assets to a versioned directory
echo $(HASH) > out/dist/git_hash
mkdir -p out/dist/v/$(HASH)
mv out/dist/main.js* out/dist/v/$(HASH)/
mv out/dist/explorer.css out/dist/v/$(HASH)/

12
app.js
View File

@@ -79,12 +79,18 @@ var hostname = opts.host;
var port = opts.port || 10240;
var staticDir = opts.static || 'static';
var archivedVersions = opts.archivedVersions;
var gitReleaseName = child_process.execSync('git rev-parse HEAD').toString().trim();
var gitReleaseName = "";
var versionedRootPrefix = "";
// Don't treat @ in paths as remote adresses
var fetchCompilersFromRemote = !opts.noRemoteFetch;
// Use the canned git_hash if provided
if (opts.static && fs.existsSync(opts.static + "/git_hash")) {
gitReleaseName = fs.readFileSync(opts.static + "/git_hash").toString().trim();
} else {
gitReleaseName = child_process.execSync('git rev-parse HEAD').toString().trim();
}
if (opts.static && fs.existsSync(opts.static + '/v/' + gitReleaseName))
versionedRootPrefix = "v/" + gitReleaseName + "/";
// Don't treat @ in paths as remote adresses
var fetchCompilersFromRemote = !opts.noRemoteFetch;
var propHierarchy = _.flatten([
'defaults',