Skip to content

Commit

Permalink
Merge pull request #4 from BIX-Digital/bugfix/split-on-undefined
Browse files Browse the repository at this point in the history
Bugfix/split on undefined
  • Loading branch information
ManuelFeller authored Feb 22, 2022
2 parents 1f0fbda + 28f71aa commit 6eb2e4d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ That is why we decided to maintain a changelog inside of the VCS that can be upd
- [3. Add the extension to your installation](#3-add-the-extension-to-your-installation)
- [4. Add your first changelog entry](#4-add-your-first-changelog-entry)
- [Release History](#release-history)
- [Version 0.8.1](#version-081)
- [Version 0.8.0](#version-080)
- [Future possibilities](#future-possibilities)

## How can I use it?
Expand Down Expand Up @@ -95,7 +97,18 @@ If you see it: congratulations, your setup works!

## Release History

- [Version 0.8.0](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.0) / 2022-02-14 -> initial release for Bitbucket
### [Version 0.8.1](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.1)

2022-02-22

- fixing a bug where a hardcoded field name (not respecting the settings) causes a crash
- improved prefix of extension in logger messages

### [Version 0.8.0](https://github.com/BIX-Digital/directus-version-control-changelog/releases/tag/v0.8.0)

2022-02-14

- initial release for Bitbucket

## Future possibilities

Expand Down
2 changes: 1 addition & 1 deletion 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": "@bix-digital/directus-extension-version-control-changelog",
"version": "0.8.0",
"version": "0.8.1",
"description": "A Directus hook extension to push user written change summaries (from a singleton collection text field) to a changelog in a VCS server",
"author": {
"name" :"BI X Digital Engineers",
Expand Down
17 changes: 12 additions & 5 deletions src/core/ChangelogWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,18 @@ export default class ChangelogWriter {

const changeUserId = this.extractUserId(userDetails[0]);
const date = new Date().toLocaleString('en-GB', { hour12: false, timeZone: 'UTC', timeZoneName: 'short' });
const newData = ChangelogFormatter.formatLatestChanges(event.payload.changes,`## ${date} by ${changeUserId}`);
const commitMsg = `Content update from Directus CMS by ${changeUserId}`;

// do the actual execution
this.vcsAbstraction.addToChangelogFile(newData, commitMsg);
const changeContent = event.payload[this.extensionConfig.fieldName];
if (changeContent !== undefined) {
const newData = ChangelogFormatter.formatLatestChanges(changeContent,`## ${date} by ${changeUserId}`);
const commitMsg = `Content update from Directus CMS by ${changeUserId}`;
// do the actual execution
this.vcsAbstraction.addToChangelogFile(newData, commitMsg);
} else {
// it seems there is a change in the monitored collection, but not in the field we're looking at
// so we warn the admin that something that might be not intended is possible
this.loggerReference.logMessage(LogLevels.warn,
'Things in the changelog collection changed, but not in the monitored field. Make sure this is wanted behavior...');
}

}

Expand Down
2 changes: 1 addition & 1 deletion src/core/ExtensionLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class ExtensionLogger {
// using "name" to have it before the message itself based on the used formatter
// --> see https://github.com/directus/directus/blob/ee7e678f24fd85846798bc3cc1af3103e728ebb7/api/src/logger.ts#L18
// and https://www.npmjs.com/package/pino-colada
this.loggerReference = directusLogger.child({name: 'Version Control Changelog Extension'});
this.loggerReference = directusLogger.child({name: 'Version Control Changelog Extension >'});
}

/**
Expand Down

0 comments on commit 6eb2e4d

Please sign in to comment.