Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ Also, check the [example](example) directory.

#### Options

Option | Type | Required | Description |
-------|------|----------|-------------
| Option | Type | Required | Description |
---------|------|----------|-------------
release | `string` | optional | unique name of a release, must be a `string`, should uniquely identify your release, defaults to `sentry-cli releases propose-version` command which should always return the correct version (**requires access to `git` CLI and root directory to be a valid repository**).
include | `string`/`array` | required | one or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files |
entries | `array`/`RegExp`/`function(key: string): bool` | optional | a filter for entry points that should be processed. By default, the release will be injected into all entry points. |
Expand All @@ -79,13 +79,17 @@ entries | `array`/`RegExp`/`function(key: string): bool` | optional | a filter f
| debug | `boolean` | optional | print some useful debug information |
| silent | `boolean` | optional | if `true`, all logs are suppressed (useful for `--json` option) |
| errorHandler | `function(err: Error, invokeErr: function(): void): void` | optional | when Cli error occurs, plugin calls this function. webpack compilation failure can be chosen by calling `invokeErr` callback or not. default `(err, invokeErr) => { invokeErr()}` |
| setCommits | `Object` | optional | Adds commits to sentry - [see own table below](#setCommits) for more details |


set-commits options:
* `commit [optional]` - `string`, the current (last) commit in the release
* `previousCommit [optional]` - `string`, the commit before the beginning of this release (in other words, the last commit of the previous release). If omitted, this will default to the last commit of the previous release in Sentry. If there was no previous release, the last 10 commits will be used
* `repo [optional]` - `string`, the full repo name as defined in Sentry
* `auto [optional]` - `boolean`, automatically choose the associated commit (uses the current commit). Overrides other options
#### <a name="setCommits"></a>options.setCommits:

| Option | Type | Required | Description |
---------|------|----------|-------------
| repo | `string` | required | the full git repo name as defined in Sentry |
| commit | `string` | optional/required | the current (last) commit in the release |
| previousCommit | `string` | optional | the commit before the beginning of this release (in other words, the last commit of the previous release). If omitted, this will default to the last commit of the previous release in Sentry. If there was no previous release, the last 10 commits will be used |
| auto | `boolean` | optional/required | automatically choose the associated commit (uses the current commit). Overrides other options |

You can find more information about these options in our official docs:
https://docs.sentry.io/cli/releases/#sentry-cli-sourcemaps
19 changes: 13 additions & 6 deletions src/__tests__/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ describe('afterEmitHook', () => {
});
});

test('test setCommits with commits range', done => {
test('test setCommits with flat options', done => {
const sentryCliPlugin = new SentryCliPlugin({
include: 'src',
release: '42',
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
repo: 'group / repo',
// auto,
auto: false,
});

sentryCliPlugin.apply(compiler);
Expand All @@ -245,26 +245,33 @@ describe('afterEmitHook', () => {
repo: 'group / repo',
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
auto: false,
});
expect(compilationDoneCallback).toBeCalled();
done();
});
});

test('test setCommits with auto option', done => {
test('test setCommits with grouped options', done => {
const sentryCliPlugin = new SentryCliPlugin({
include: 'src',
release: '42',
repo: 'group / repo',
auto: true,
setCommits: {
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
repo: 'group / repo',
auto: false,
},
});

sentryCliPlugin.apply(compiler);

setImmediate(() => {
expect(mockCli.releases.setCommits).toBeCalledWith('42', {
repo: 'group / repo',
auto: true,
commit: '4d8656426ca13eab19581499da93408e30fdd9ef',
previousCommit: 'b6b0e11e74fd55836d3299cef88531b2a34c2514',
auto: false,
});
expect(compilationDoneCallback).toBeCalled();
done();
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ class SentryCliPlugin {
})
.then(() => this.cli.releases.uploadSourceMaps(release, this.options))
.then(() => {
const { commit, previousCommit, repo, auto } = this.options;
const { commit, previousCommit, repo, auto } =
this.options.setCommits || this.options;

if (repo && (commit || auto)) {
this.cli.releases.setCommits(release, {
Expand Down