Skip to content

Commit

Permalink
skip empty commit (e.g. page move)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eccenux committed Jul 15, 2023
1 parent 552271a commit b4304d4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
24 changes: 11 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wiki-to-git",
"version": "1.0.0",
"version": "1.0.1",
"description": "Node.js tool that helps to download Mediwiki page history and push it to a Git repository.",
"type": "module",
"main": "src/main.js",
Expand Down
20 changes: 16 additions & 4 deletions src/GitOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,22 @@ export default class GitOps {
args.push(this.pDate(history));
let env = {};
env.GIT_COMMITTER_DATE = history.dt.toString().trim();
const result = await this.execFile('git', args, this.dir, env);
if (!result) {
throw 'Unable to commit changes!';

let result;
try {
result = await this.execFile('git', args, this.dir, env);
if (!result) {
throw 'Unable to commit changes!';
}
} catch (error) {
if (error.code === 1 && error.stdout.search(/nothing to commit/) >= 0) {
console.log('\n\nskipping empty commit:\n', history);
} else {
this.execInfo(error.stdout, error.stderr);
throw(error);
}
}

return result;
}

Expand Down Expand Up @@ -120,7 +132,7 @@ export default class GitOps {
}

/** @private Report exec problems. */
async execInfo(stdout, stderr) {
execInfo(stdout, stderr) {
if (stdout && stdout.length) {
console.log(stdout);
}
Expand Down

0 comments on commit b4304d4

Please sign in to comment.