Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#7558)[webpack]: handle git errors gracefully and clearly #7562

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion .webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import CopyWebpackPlugin from 'copy-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import { VueLoaderPlugin } from 'vue-loader';
import webpack from 'webpack';

const REV_PARSE_ERROR =
'[WARN]: Failed to retrieve Git commit metadata. This might indicate that the script is not running within a Git repository. Error details:';
let gitRevision = 'error-retrieving-revision';
let gitBranch = 'error-retrieving-branch';

Expand All @@ -24,7 +27,9 @@ try {
gitRevision = execSync('git rev-parse HEAD').toString().trim();
gitBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
} catch (err) {
console.warn(err);
console.warn(`${REV_PARSE_ERROR}
"${err}"
Continuing...`);
}

const projectRootDir = fileURLToPath(new URL('../', import.meta.url));
Expand Down