Git Product home page Git Product logo

git-revision-webpack-plugin's People

Contributors

dependabot[bot] avatar jansauer avatar karlhorky avatar mawi12345 avatar mlandauer avatar nevon avatar pirelenito avatar robclemons avatar seiyria avatar simonfyi avatar tartineskiller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

git-revision-webpack-plugin's Issues

lastCommitDateTimeCommand: Invalid object name %H

I tried customising the format of the last commit date and it works in Git bash, but I get the following error when I try to compile with webpack

const gitRevision = new GitRevisionPlugin({
  branch: true,
  lastCommitDateTimeCommand:
    "log -1 --pretty='%cd' --date=format:'%d/%m/%Y %H:%M:%S'",
})
Error: Command failed: git log -1 --pretty='%cd' --date=format:'%d/%m/%Y %H:%M:%S'
fatal: invalid object name '%H'.

I think that could be some problem about the quotes

Unable to load 4.0 using require()

After upgrading to 4.0, I can no longer load as per the documentation, i.e., require the library, call new Plugin(). Calling new Plugin.default() does work.

The library implementation has an exports.default, so that's not unexpected. I think you'd want a module.exports there instead, given that you're seemingly still going for CJS compatibility here.

Add date to version

Currently my version looks like
1.1-59-gdcd4eea

I would like to append the last commit date to the version string:
1.1-0-gdcd4eea-2018-12-30

This version should be saved to the VERSION file.

Issue #26 is related, but not the same.

It does not do anything with Angular

EDITED
I found a solution: Declare VERSION, COMMITHASH and BRANCH as follows:
declare var VERSION:string, COMMITHASH:string, BRANCH:string
And then in the Component i saved the values in variables:
version:string = VERSION
The problem that I had was because of TypeScript. In TypeScript I had to declare them first.

I am using webpack 3 and angular 5 in my project.
I defined a new plugin in webpack as shown in the readme, and added {{ VERSION }} in my angular component template, but unfortunately it did not show anything. It does not throw any error though.

I added this in the webpack config file:

const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();

plugins: [
    new DefinePlugin({
      'VERSION': JSON.stringify(gitRevisionPlugin.version()),
      'COMMITHASH': JSON.stringify(gitRevisionPlugin.commithash()),
      'BRANCH': JSON.stringify(gitRevisionPlugin.branch()),
    }),
  ]

Have I done something wrong, or does it not work the way I have used it at all?
Thank you in advance!

Fails on Heroku

When I deploy to Heroku, git-revision-plugin fails with an error about Git repositories not being available.

I'm not sure why that happens. Heroku deploys work with git push and to the best of my knowledge the require you to compile Webpack in a post-commit hook of some sort.

Here's my setup:

new webpack.DefinePlugin({
            BUILD_VERSION: JSON.stringify(new GitRevisionPlugin().commithash())
        })

Here's the error:

remote:        fatal: Not a git repository (or any parent up to mount point /tmp)
remote:        Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:        child_process.js:526
remote:        throw err;
remote:        ^
remote:        Error: Command failed: git rev-parse HEAD
remote:        fatal: Not a git repository (or any parent up to mount point /tmp)
remote:        Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
remote:        at checkExecSyncError (child_process.js:483:13)
remote:        at execSync (child_process.js:523:13)
remote:        at module.exports (/tmp/build_18cd9bb16de5850f2c050bdfd437c15e/node_modules/git-revision-webpack-plugin/lib/helpers/run-git-command.js:25:34)
remote:        at GitRevisionPlugin.commithash (/tmp/build_18cd9bb16de5850f2c050bdfd437c15e/node_modules/git-revision-webpack-plugin/lib/index.js:58:10)
remote:        at Object.<anonymous> (/tmp/build_18cd9bb16de5850f2c050bdfd437c15e/webpack.config.babel.js:164:67)
remote:        at Module._compile (module.js:570:32)
remote:        at loader (/tmp/build_18cd9bb16de5850f2c050bdfd437c15e/node_modules/babel-register/lib/node.js:144:5)
remote:        at Object.require.extensions.(anonymous function) [as .js] (/tmp/build_18cd9bb16de5850f2c050bdfd437c15e/node_modules/babel-register/lib/node.js:154:7)
remote:        at Module.load (module.js:487:32)
remote:        at tryModuleLoad (module.js:446:12)
remote:        D, [2017-11-27T20:36:28.001511 #875] DEBUG -- : ** [Raven] Event not sent due to excluded environment: qa-3
remote:        rake aborted!
remote:        Command failed with status (1): [$(npm bin)/webpack --config webpack.config...]
remote:        /tmp/build_18cd9bb16de5850f2c050bdfd437c15e/lib/tasks/assets.rake:19:in `block (2 levels) in <top (required)>'
remote:        Tasks: TOP => assets:precompile => assets:compile_environment => assets:webpack
remote:        (See full trace by running task with --trace)

Plugin doesn't create files

I'm using the plugin as described in the Readme, but it's not creating any files.
The project is built inside docker, using [email protected] and [email protected].
But the plugin seems to be calling git, because when git is not installed inside docker, it fails with Error: Command failed: git rev-parse HEAD
/bin/sh: 1: git: not found.
So after installing git inside docker, it's not failing and not giving any error, so it's calling git but not writing these files for some reason.
Any idea why?

Incorrect npm install command

If you have --save-dev before the package name it doesn't actually update the package.json

I jsut ran into this issue when I pushed to server it failed since package.json wasn't updated.

It should be

npm install git-revision-webpack-plugin --save-dev

is it possible to specify repository path?

I want to get the commit hash of a repository which is outside the current path, so is it possible to give a path to a repository?

something like

gitRevisionPlugin.commithash(path: '/path/to/repo')

Cant eaccess prototype functions in code

when I try to use 'VERSION': JSON.stringify(GitRevisionPlugin.version()) I get the following response
Inner Exception 1: Exception: Call to Node module failed with error: TypeError: GitRevisionPlugin.version is not a function
I am using the code like this

new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(isDevBuild ? 'Development' : 'Production'), 'VERSION': JSON.stringify(GitRevisionPlugin.version()) } })

new GitRevisionPlugin() does work on its own and writes the files.

allow to specify git dirty mark

Sometimes I want to include is git working tree is dirty or not into version string, i.e. run with --dirty flag:

$ git describe --always --tags --dirty
0.0.1-2-g51be290-dirty

It would be convenient to be able to do so using git-revision-webpack-plugin, e.g.:

module.exports = {
  plugins: [
    new GitRevisionPlugin({dirtyMark: true})
  ]
}

or new GitRevisionPlugin({dirtyMark: '-wip'}).

Plugin triggers error with Angular 12 AngularWebpackPlugin

Hello! I'm transitioning an application from Angular 11 to 12 and the build fails when utilizing this plugin alongside the AngularWebpackPlugin.

The following error is raised during compilation:

/app/node_modules/@ngtools/webpack/src/resource_loader.js:207
                            throw new Error(`'${name}' asset info 'sourceFilename' is 'undefined'.`);
                            ^

Error: 'COMMITHASH' asset info 'sourceFilename' is 'undefined'.
    at /app/node_modules/@ngtools/webpack/src/resource_loader.js:207:35
    at /app/node_modules/webpack/lib/Compiler.js:538:11
    at /app/node_modules/webpack/lib/Compiler.js:1106:17
    at Hook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/app/node_modules/tapable/lib/Hook.js:18:14)
    at /app/node_modules/webpack/lib/Compiler.js:1102:33
    at finalCallback (/app/node_modules/webpack/lib/Compilation.js:2249:11)
    at /app/node_modules/webpack/lib/Compilation.js:2540:11
    at Hook.eval [as callAsync] (eval at create (/app/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/app/node_modules/tapable/lib/Hook.js:18:14)

Here is the line in question in the AngularWebpackPlugin: https://github.com/angular/angular-cli/blob/736a5f89deaca85f487b78aec9ff66d4118ceb6a/packages/ngtools/webpack/src/resource_loader.ts#L279-L284

The build completes successfully if I rewrite line 280 of the previous source to the following line:

if (info.sourceFilename === undefined && !['VERSION', 'COMMITHASH', 'LASTCOMMITDATETIME', 'BRANCH'].includes(name)) {

I'm not certain if the check in the AngularWebpackPlugin should be adjusted or if extra information needs to be attached to the assets produced from this plugin, but figured I'd start with raising the issue here.

error occurs without any commits

Hello, Thanks for the cool plugin!

when I try to use with a git repository without any commits, it fails.

$ git log
fatal: your current branch 'master' does not have any commits yet
$ node
> const GitRevisionPlugin = require('git-revision-webpack-plugin')
undefined
> const gitRevisionPlugin = new GitRevisionPlugin()
undefined
> JSON.stringify(gitRevisionPlugin.version())
fatal: Not a valid object name HEAD
Error: Command failed: git describe --always
fatal: Not a valid object name HEAD

    at checkExecSyncError (child_process.js:591:13)
    at execSync (child_process.js:631:13)
    at module.exports (/Users/kamataryo/Desktop/sample/node_modules/git-revision-webpack-plugin/lib/helpers/run-git-command.js:25:34)
    at GitRevisionPlugin.version (/Users/kamataryo/Desktop/sample/node_modules/git-revision-webpack-plugin/lib/index.js:65:10)
    at repl:1:34
    at ContextifyScript.Script.runInThisContext (vm.js:44:33)
    at REPLServer.defaultEval (repl.js:239:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:440:10)
> 

Warning when work with webpack 5

Webpack 5 is now in beta now, this awesome plugin triggers a warning when work with it:

[DEP_WEBPACK_MAIN_TEMPLATE_ASSET_PATH] DeprecationWarning: MainTemplate.hooks.assetPath is deprecated (use Compilation.hooks.assetPath instead)

Add branch name

It would be nice if this plugin could also fetch the branch name and if its dirty.

Cannot read 'compilation' of undefined

Hello!

I try to use your plugin with Webpack 2.1.0 and I get following error:

C:\Projekty\web-frontend\node_modules\git-revision-webpack-plugin\lib\build-file.js:6
  compiler.hooks.compilation.tap('compilation', (compilation) => {
                ^

TypeError: Cannot read property 'compilation' of undefined
at buildFile (C:\Projekty\web-frontend\node_modules\git-revision-webpack-plugin\lib\build-file.js:6:17)
    at GitRevisionPlugin.apply (C:\Projekty\web-frontend\node_modules\git-revision-webpack-plugin\lib\index.js:30:3)
    at Compiler.apply (C:\Projekty\web-frontend\node_modules\tapable\lib\Tapable.js:375:16)
    at WebpackOptionsApply.process (C:\Projekty\web-frontend\node_modules\webpack\lib\WebpackOptionsApply.js:58:18)
    at webpack (C:\Projekty\web-frontend\node_modules\webpack\lib\webpack.js:25:48)
    at Object.<anonymous> (C:\Projekty\web-frontend\conf\browsersync.conf.js:8:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Function.Module._load (C:\Projekty\web-frontend\node_modules\gulp-hub\lib\load-subfile.js:26:32)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Projekty\web-frontend\gulp_tasks\browsersync.js:5:25)
    at Module._compile (module.js:570:32)

Is it possible to run it with Webpack 2?

huntr.dev - Command Injection

Vulnerability Description

The function commithash within lib/helpers/run-git-command.js takes user input, and is passed to the gitCommand argument without any sanitization.

Steps To Reproduce:

var Root = require("git-revision-webpack-plugin");
var opt = {
"gitWorkTree": "& echo vulnerable > create.txt &"
 }
var root = new Root(opt);
root.commithash();

Bug Bounty

We have opened up a bounty for this issue on our bug bounty platform. Want to solve this vulnerability and get rewarded ๐Ÿ’ฐ? Go to https://huntr.dev/

Update mocha

The "mocha" package is currently listed with version "^5.0.4". I recommend updating it to "^8.3.2".

No longer maintained?

Hi @pirelenito,

It's been nearly a year without any code movement in this repository. Is it still being maintained, or will you be seeking new maintainer(s)? There are some outstanding bugs in need of addressing.

Path substitutions don't work with BannerPlugin?

Hi,

I tried configuration like this:

plugins: [
  new GitRevisionPlugin(),
  new webpack.BannerPlugin({
    banner: '[git-revision-version]',
   }),
],

It didn't end up replacing the banner content, though, so [git-revision-version] went through.

The following solution works:

new webpack.BannerPlugin({
  banner: new GitRevisionPlugin.version(),
}),

This could be a webpack bug, but just thought to let you know. At least you might want to document this gotcha. Thanks for the plugin. ๐Ÿ‘

(Question): Don't output files

This is not an issue but a question, if I am not interested in generating the files, just interested in path substitution [git-revision-hash] is there a way to configure it to not output the VERSION and COMMITHASH files?

Use git log instead git rev-parse to get current branch

git rev-parse --abbrev-ref HEAD isn't very helpful, as it always returns HEAD when you're in detached HEAD state (i.e. when deploying via gitlab).

I suggest using git log -n 1 --pretty=%d HEAD instead, in detached HEAD state it produces a more meaningful output:
(HEAD, origin/sandbox/test_git_revision_plugin)

Improvement/rollback: lower (or don't specify) engine.node version requirement

3.x.x introduces engines.node as >=8.0.0 in package.json.

Installing git-revision-webpack-plugin with yarn throws an error when running node 6.x because of the above. This breaks a lot of production builds on servers running older Node LTS (6.x).

I ran the test and they pass with node 6.14.2, and I tested with webpack4 boilerplate (https://github.com/cvgellhorn/webpack-boilerplate) to see if I can actually get the hash in-code and it works.

Not to say these tests are empirical, but it seems like requiring node>=8 isn't needed.

Suggested fix:
a) lower engines.node to 6.x (or even lower if if works)
b) remove the requirement completely, as it seems to do more harm than good

Problem to render [git-revision-hash] inside css

Hi,

I have the problem that resources that are loaded from the (s)css are not rendered with the [git-revision-hash].
However, only when I am in normal webpack build mode.
When I start webpack --watch everything works.

so webpack (build) => url(/assets/fonts/myFont-Regular.[git-revision-hash].woff2) format("woff2"),
and webpack --watch => url(/assets/fonts/myFont-Regular.946a26b9.woff2) format("woff2"),

I am attaching the webpack.config. Maybe someone can help me further.

'use strict';
const path = require('path');
const webpack = require('webpack');
const packageJSON = require('./package.json');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const FantasticonPlugin = require('fantasticon-webpack-plugin');

const {GitRevisionPlugin} = require('git-revision-webpack-plugin');

module.exports = {
    target: 'web',
    mode: process.env.APP_ENV === 'production' ? 'production' : 'development',
    devtool: process.env.APP_ENV === 'production' ? false : 'inline-source-map',
    entry: {
        main: [
            path.resolve(__dirname, './src/assets/scripts/main.js'),
            path.resolve(__dirname, './src/assets/styles/main.scss'),
        ],

        // workaround to copy fonts into dist folder - do not remove until we find a proper way!
        // ignore fonts.css in dist folder!
        fonts: path.resolve(__dirname, './src/assets/styles/fonts.scss')
    },
    output: {
        path: path.resolve(__dirname, './dist'),
        publicPath: packageJSON.project.publicPath + '/',
        filename: 'js/[name].[git-revision-hash].js',
        clean: true,
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env'],
                    },
                },
            },

            {
                test: /\.s[ac]ss$/i,
                use: [
                    MiniCssExtractPlugin.loader,
                    'css-loader',
                    {
                        loader: 'postcss-loader',
                        options: {
                            postcssOptions: {
                                // https://github.com/csstools/postcss-plugins/tree/main/plugin-packs/postcss-preset-env
                                // the stage option determines which CSS features to polyfill
                                // disable every polyfill: false
                                // stable: 4

                                plugins: [['postcss-preset-env', {stage: 4}]],
                            },
                        },
                    },
                    'sass-loader',
                ],
            },

            // svg: created as data url
            /*{
                test: /\.svg$/i,
                type: 'asset/inline'
            },*/
            {
                test: /\.(png|jpg|gif)$/,
                type: 'asset/resource',
                generator: {
                    filename: 'images/[name].[git-revision-hash][ext]',
                },
            },


            {
                test: /\.svg$/i,
                type: 'asset/resource',
                generator: {
                    filename: 'vectors/[name][ext]',
                },
                // https://webpack.js.org/plugins/image-minimizer-webpack-plugin/#standalone-loader
            },
            {
                test: /\.(woff|woff2)$/,
                type: 'asset/resource',
                generator: {
                    filename: 'fonts/[name].[git-revision-hash][ext]',
                },
            },
        ],
    },
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src'),
            toolbox: path.resolve(__dirname, './src/assets/scripts/utilities/toolbox'),
        },
        extensions: [
            '.sass',
            '.scss',
            '.css',
            '.wasm',
            '.web.js',
            '.mjs',
            '.js',
            '.json',
            '.web.jsx',
            '.svg',
            '.png',
            '.jpg',
            '.webp',
            '.jpeg',
            '.jsx',
            '.woff',
            '.woff2',
        ],
    },
    plugins: [
        new GitRevisionPlugin({
            commithashCommand: 'rev-parse --short HEAD',
        }),
        new CopyPlugin({
            patterns: [
                {
                    from: '**/*.svg',
                    to: '../src/patterns/fundamentals/vectors/v-[name].hbs',
                    context: 'src/assets/vectors',
                },
                {
                    from: '**/*.hbs',
                    to: 'patterns/',
                    context: 'src/patterns',
                },

                {
                    from: '**/*.*',
                    to: 'images/',
                    context: 'src/assets/images',
                },
            ],
        }),
        new FantasticonPlugin({
            runOnComplete: false, //optional
            //onComplete: (fontConfig) => {}, //optional
            //configPath: 'myconfig.js', //optional
            //config: { ... } //optional
        }),
        new MiniCssExtractPlugin({
            filename: 'css/[name].[git-revision-hash].css',
        }),
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
            toolbox: 'toolbox',
        }),
    ],
    optimization: {
        minimizer: [
            '...', // keep the existing minimizer of webpack, which is terser (minimizes js files)
            new CssMinimizerPlugin({
                // css optimization only in production mode
                // https://webpack.js.org/plugins/css-minimizer-webpack-plugin/#remove-all-comments
                minimizerOptions: {
                    preset: [
                        'default',
                        {
                            discardComments: {removeAll: true},
                        },
                    ],
                },
            }),

            new ImageMinimizerPlugin({
                minimizer: {
                    implementation: ImageMinimizerPlugin.svgoMinify,
                    options: {
                        encodeOptions: {
                            // Pass over SVGs multiple times to ensure all optimizations are applied. False by default
                            multipass: true,
                            plugins: [
                                // set of built-in plugins enabled by default
                                // see: https://github.com/svg/svgo#default-preset
                                {
                                    name: 'preset-default',

                                    params: {
                                        overrides: {
                                            // customize default plugin options
                                            inlineStyles: {
                                                onlyMatchedOnce: false,
                                            },

                                            // or disable plugins
                                            removeDoctype: false,
                                            cleanupIDs: false,
                                        },
                                    },
                                },
                                {
                                    name: 'prefixIds',
                                },
                            ],
                        },
                    },
                },
            }),
        ],
    },
};

๐Ÿšจ Potential Command Injection - Generic (CWE-77)

๐Ÿ‘‹ Hello, @pirelenito - a potential high severity Command Injection - Generic (CWE-77) vulnerability in your repository has been disclosed to us.

Next Steps

1๏ธโƒฃ Visit https://huntr.dev/bounties/2-other-pirelenito/git-revision-webpack-plugin for more advisory information.

2๏ธโƒฃ Sign-up to validate or speak to the researcher for more assistance.

3๏ธโƒฃ Propose a patch or outsource it to our community - whoever fixes it gets paid.

โœ๏ธ NOTE: If we don't hear from you in 14 days, we will proactively source a fix for this vulnerability (and open a PR) to ensure community safety.


Confused or need more help?

  • Join us on our Discord and a member of our team will be happy to help! ๐Ÿค—

  • Speak to a member of our team: @JamieSlome


This issue was automatically generated by huntr.dev - a bug bounty board for securing open source code.

Support for webpack 4

This plugin cause DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead

DeprecationWarning: Tapable.plugin is deprecated. Use new API on .hooks instead
at buildFile (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\git-revision-webpack-plugin\lib\build-file.js:6:12)
at GitRevisionPlugin.apply (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\git-revision-webpack-plugin\lib\index.js:30:3)
at webpack (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack\lib\webpack.js:37:12)
at processOptions (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack-cli\bin\webpack.js:427:16)
at yargs.parse (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack-cli\bin\webpack.js:502:3)
at Object.parse (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack-cli\node_modules\yargs\yargs.js:539:18)
at C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack-cli\bin\webpack.js:212:8
at Object. (C:\Users\b1f6c1c4\Documents\Github\ballot\frontend\node_modules\webpack-cli\bin\webpack.js:504:3)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
at Function.Module.runMain (module.js:701:10)
at startup (bootstrap_node.js:194:16)
at bootstrap_node.js:618:3

SubModule support suggestion

When the repo is a submodule of an other, the plugin raise a "not git repository" error,
it could be great to be able to reference the .git folder or perhaps recurse up to the main repository ?

Pre-hook fetch to ensure local git is up to date with remote

The ability to undertake a fetch as a pre-hook to ensure that the local git is up to date with remote would be useful.

At the moment I need to run this in CI to ensure that, particularly the tags, are up to date.

git fetch --all --tags

npm run build

A pre-hook that could run the fetch would be great.

Add Author

Hi, thanks for this great plugin.

Could you add the Author command?

git show -s --pretty=%an

output.filename as function doesn't work

With latest webpack (4.26.1) using options.filename with a function throws error when adding GitRevisionPlugin to plugins array

return {
        entry: {
            app: `./${SRCFOLDER}/entrypoints/main.js`
        },
        output: {
            filename: () => 'test.js' 
            // with example function from docs same error
            filename: (chunkData) => {
                 return chunkData.chunk.name === 'main' ? '[name].js': '[name]/[name].js';
           },
        },
 ...

        plugins: [
            new GitRevisionPlugin({
                versionCommand: 'describe --always --tags --abbrev=0'
            }),

Console output:

ERROR in chunk app [entry]
() => 'test.js'
path.replace is not a function
error Command failed with exit code 2.

Other relevant information:
webpack version: 4.26.1
Node.js version: 8.11.2
Operating System: windows 10
Additional tools:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.