This commit is contained in:
parent
c28cc0c9e7
commit
2ecafd3354
@ -113,6 +113,50 @@ describe('formatters', () => {
|
|||||||
).toEqual('Custom commit message');
|
).toEqual('Custom commit message');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use empty values if "authorLogin" and "authorName" are missing in commit message', () => {
|
||||||
|
config.getIn.mockReturnValueOnce(
|
||||||
|
Map({
|
||||||
|
update: '{{author-login}} - {{author-name}}: Create {{collection}} “{{slug}}”',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
commitMessageFormatter(
|
||||||
|
'update',
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
slug: 'doc-slug',
|
||||||
|
path: 'file-path',
|
||||||
|
collection,
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
).toEqual(' - : Create Collection “doc-slug”');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return custom create message with author information', () => {
|
||||||
|
config.getIn.mockReturnValueOnce(
|
||||||
|
Map({
|
||||||
|
create: '{{author-login}} - {{author-name}}: Create {{collection}} “{{slug}}”',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
commitMessageFormatter(
|
||||||
|
'create',
|
||||||
|
config,
|
||||||
|
{
|
||||||
|
slug: 'doc-slug',
|
||||||
|
path: 'file-path',
|
||||||
|
collection,
|
||||||
|
authorLogin: 'user-login',
|
||||||
|
authorName: 'Test User',
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
).toEqual('user-login - Test User: Create Collection “doc-slug”');
|
||||||
|
});
|
||||||
|
|
||||||
it('should return custom open authoring message', () => {
|
it('should return custom open authoring message', () => {
|
||||||
config.getIn.mockReturnValueOnce(
|
config.getIn.mockReturnValueOnce(
|
||||||
Map({
|
Map({
|
||||||
|
@ -57,6 +57,10 @@ export const commitMessageFormatter = (
|
|||||||
return path || '';
|
return path || '';
|
||||||
case 'collection':
|
case 'collection':
|
||||||
return collection ? collection.get('label_singular') || collection.get('label') : '';
|
return collection ? collection.get('label_singular') || collection.get('label') : '';
|
||||||
|
case 'author-login':
|
||||||
|
return authorLogin || '';
|
||||||
|
case 'author-name':
|
||||||
|
return authorName || '';
|
||||||
default:
|
default:
|
||||||
console.warn(`Ignoring unknown variable “${variable}” in commit message template.`);
|
console.warn(`Ignoring unknown variable “${variable}” in commit message template.`);
|
||||||
return '';
|
return '';
|
||||||
|
@ -349,14 +349,14 @@ backend:
|
|||||||
|
|
||||||
Netlify CMS generates the following commit types:
|
Netlify CMS generates the following commit types:
|
||||||
|
|
||||||
| Commit type | When is it triggered? | Available template tags |
|
| Commit type | When is it triggered? | Available template tags |
|
||||||
| --------------- | ---------------------------------------- | ---------------------------------------- |
|
| --------------- | ---------------------------------------- | ----------------------------------------------------------- |
|
||||||
| `create` | A new entry is created | `slug`, `path`, `collection` |
|
| `create` | A new entry is created | `slug`, `path`, `collection`, `author-login`, `author-name` |
|
||||||
| `update` | An existing entry is changed | `slug`, `path`, `collection` |
|
| `update` | An existing entry is changed | `slug`, `path`, `collection`, `author-login`, `author-name` |
|
||||||
| `delete` | An exising entry is deleted | `slug`, `path`, `collection` |
|
| `delete` | An exising entry is deleted | `slug`, `path`, `collection`, `author-login`, `author-name` |
|
||||||
| `uploadMedia` | A media file is uploaded | `path` |
|
| `uploadMedia` | A media file is uploaded | `path`, `author-login`, `author-name` |
|
||||||
| `deleteMedia` | A media file is deleted | `path` |
|
| `deleteMedia` | A media file is deleted | `path`, `author-login`, `author-name` |
|
||||||
| `openAuthoring` | A commit is made via a forked repository | `message`, `author-login`, `author-name` |
|
| `openAuthoring` | A commit is made via a forked repository | `message`, `author-login`, `author-name` |
|
||||||
|
|
||||||
Template tags produce the following output:
|
Template tags produce the following output:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user