Skip to content

Commit 359e915

Browse files
authored
Merge pull request #475 from crazy-max/commit-date-changes
commit_date: code cleanup and readme updates
2 parents 1156622 + 0c395eb commit 359e915

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ ___
4545
* [`{{base_ref}}`](#base_ref)
4646
* [`{{is_default_branch}}`](#is_default_branch)
4747
* [`{{date '<format>' tz='<timezone>'}}`](#date-format-tztimezone)
48+
* [`{{commit_date '<format>' tz='<timezone>'}}`](#commit_date-format-tztimezone)
4849
* [Major version zero](#major-version-zero)
4950
* [JSON output object](#json-output-object)
5051
* [Overwrite labels and annotations](#overwrite-labels-and-annotations)
@@ -891,13 +892,14 @@ Default `tz` is UTC.
891892

892893
#### `{{commit_date '<format>' tz='<timezone>'}}`
893894

894-
Returns the date when current git commit is committed.
895-
rendered by its [moment format](https://momentjs.com/docs/#/displaying/format/).
895+
Returns the date when the current git commit is committed, rendered by its
896+
[moment format](https://momentjs.com/docs/#/displaying/format/). It falls back
897+
to the current date if the commit date is not available.
896898

897899
Default `tz` is UTC.
898900

899-
| Expression | Output example |
900-
|----------------------------------------------|-----------------------------------------|
901+
| Expression | Output example |
902+
|-----------------------------------------------------|-----------------------------------------|
901903
| `{{commit_date 'YYYYMMDD'}}` | `20200110` |
902904
| `{{commit_date 'dddd, MMMM Do YYYY, h:mm:ss a'}}` | `Friday, January 10th 2020, 3:25:50 pm` |
903905
| `{{commit_date 'YYYYMMDD-HHmmss' tz='Asia/Tokyo'}}` | `20200110-093000` |

__tests__/context.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import * as path from 'path';
55
import {Context} from '@actions/github/lib/context';
66
import {Git} from '@docker/actions-toolkit/lib/git';
77
import {GitHub} from '@docker/actions-toolkit/lib/github';
8+
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
89

910
import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
10-
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
1111

1212
const toolkit = new Toolkit({githubToken: 'fake-github-token'});
1313

__tests__/meta.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import {beforeEach, describe, expect, jest, test} from '@jest/globals';
22
import * as fs from 'fs';
33
import * as path from 'path';
44
import * as dotenv from 'dotenv';
5+
6+
import {Context} from '@actions/github/lib/context';
57
import {GitHub} from '@docker/actions-toolkit/lib/github';
68
import {Toolkit} from '@docker/actions-toolkit/lib/toolkit';
79
import {GitHubRepo} from '@docker/actions-toolkit/lib/types/github';
8-
import {Context} from '@actions/github/lib/context';
910

1011
import {ContextSource, getContext, getInputs, Inputs} from '../src/context';
1112
import {Meta, Version} from '../src/meta';

0 commit comments

Comments
 (0)