From ae22af33a92dbe9d38f1d1d117937a2f8493e4f3 Mon Sep 17 00:00:00 2001 From: eccenux Date: Thu, 13 Jul 2023 02:35:21 +0200 Subject: [PATCH] GitOps commit * date param --- src/GitOps.js | 4 +++- test/GitOps.test.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/GitOps.js b/src/GitOps.js index 70bfac4..9cbb1b4 100644 --- a/src/GitOps.js +++ b/src/GitOps.js @@ -87,7 +87,9 @@ export default class GitOps { /** @private Date param. */ pDate(history) { // git commit ... --date='' - args.push('--date='); args.push(history.dt); + let dt = history.dt.toString().trim(); + let arg = `--date='${dt}'`; + return arg; } /** @private Execute and report problems (unsafe!). */ diff --git a/test/GitOps.test.js b/test/GitOps.test.js index ce3ca2b..74371cf 100644 --- a/test/GitOps.test.js +++ b/test/GitOps.test.js @@ -34,5 +34,21 @@ describe('GitOps', function () { assert.equal(result, expected); }); }); + + describe('pDate', function () { + const git = new GitOps('./repo', 'test-repo'); + function createEntry(dt) { + const history = {dt: dt, author: 'Johnny', id: 123, message: 'v1.2.3'}; + return history; + } + + it('should format param', function () { + let dt = '2023-01-22T19:52:05Z'; + let history = createEntry(dt); + let result = git.pDate(history); + let expected = `--date='${dt}'`; + assert.equal(result, expected); + }); + }); }); // assert.isTrue(loader.history.length > 50);