Skip to content

Commit

Permalink
GitOps commit
Browse files Browse the repository at this point in the history
* date param
  • Loading branch information
Eccenux committed Jul 13, 2023
1 parent e1a6948 commit ae22af3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/GitOps.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ export default class GitOps {
/** @private Date param. */
pDate(history) {
// git commit ... --date='<ISO 8601>'
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!). */
Expand Down
16 changes: 16 additions & 0 deletions test/GitOps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit ae22af3

Please sign in to comment.