Browse Source

Use export-subst gitattribute to allow tarball builds

For example it would do the following:

    let subst = "d3bf557c";
Haelwenn (lanodan) Monnier 1 year ago
parent
commit
6e5c7bf308
3 changed files with 12 additions and 3 deletions
  1. 1 0
      .gitattributes
  2. 10 3
      build/webpack.prod.conf.js
  3. 1 0
      changelog.d/export-subst-hash.fix

+ 1 - 0
.gitattributes

@@ -0,0 +1 @@
+/build/webpack.prod.conf.js export-subst

+ 10 - 3
build/webpack.prod.conf.js

@@ -11,9 +11,16 @@ var env = process.env.NODE_ENV === 'testing'
     ? require('../config/test.env')
     : config.build.env
 
-let commitHash = require('child_process')
-    .execSync('git rev-parse --short HEAD')
-    .toString();
+let commitHash = (() => {
+  let subst = "$Format:%h$";
+  if(!subst.match(/Format:/)) {
+    return subst;
+  } else {
+    return require('child_process')
+      .execSync('git rev-parse --short HEAD')
+      .toString();
+  }
+})();
 
 var webpackConfig = merge(baseWebpackConfig, {
   mode: 'production',

+ 1 - 0
changelog.d/export-subst-hash.fix

@@ -0,0 +1 @@
+Use export-subst gitattribute to allow tarball builds