Skip to content

Commit

Permalink
Merge pull request #587 from reg-viz/feat-short-desc
Browse files Browse the repository at this point in the history
Feat short desc
  • Loading branch information
Quramy committed Jun 8, 2022
2 parents 56953c0 + 0ee5da1 commit e9800ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/reg-notify-github-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ If reg-suit detects visual differences, it set the commit status failure. Someti
prComment?: boolean;
prCommentBehavior?: "default" | "once" | "new";
setCommitStatus?: boolean;
shortDescription?: boolean;
}
```

Expand All @@ -47,3 +48,9 @@ If reg-suit detects visual differences, it set the commit status failure. Someti
- `"new"` : Delete existing old comment and post new comment.
- `"once"` : Does nothing if the PR comment exists.
- `setCommitStatus` - _Optional_ - Whether to allow reg-suit to set commit status to fail if any visual differences are detected. Default: `true`.
- `shortDescription` - _Optional_ Returns a small table with the item counts.
Example:

| 🔴 Changed | ⚪️ New | 🔵 Passing |
| ---------- | ------- | ---------- |
| 3 | 4 | 120 |
12 changes: 11 additions & 1 deletion packages/reg-notify-github-plugin/src/github-notifier-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface GitHubPluginOption {
prCommentBehavior?: PrCommentBehavior;
setCommitStatus?: boolean;
customEndpoint?: string;
shortDescription?: boolean;
}

interface GhAppStatusCodeError {
Expand Down Expand Up @@ -50,6 +51,7 @@ export class GitHubNotifierPlugin implements NotifierPlugin<GitHubPluginOption>
_prComment!: boolean;
_setCommitStatus!: boolean;
_behavior!: PrCommentBehavior;
_shortDescription!: boolean;

_apiPrefix!: string;
_repo!: Repository;
Expand All @@ -75,6 +77,7 @@ export class GitHubNotifierPlugin implements NotifierPlugin<GitHubPluginOption>
this._prComment = config.options.prComment !== false;
this._behavior = config.options.prCommentBehavior ?? "default";
this._setCommitStatus = config.options.setCommitStatus !== false;
this._shortDescription = config.options.shortDescription ?? false;
this._apiPrefix = config.options.customEndpoint || getGhAppInfo().endpoint;
this._repo = new Repository(path.join(fsUtil.prjRootDir(".git"), ".git"));
}
Expand Down Expand Up @@ -107,7 +110,13 @@ export class GitHubNotifierPlugin implements NotifierPlugin<GitHubPluginOption>
};
if (params.reportUrl) updateStatusBody.reportUrl = params.reportUrl;
if (this._prComment) {
updateStatusBody.metadata = { failedItemsCount, newItemsCount, deletedItemsCount, passedItemsCount };
updateStatusBody.metadata = {
failedItemsCount,
newItemsCount,
deletedItemsCount,
passedItemsCount,
shortDescription: this._shortDescription,
};
}

const reqs = [];
Expand Down Expand Up @@ -135,6 +144,7 @@ export class GitHubNotifierPlugin implements NotifierPlugin<GitHubPluginOption>
newItemsCount,
deletedItemsCount,
passedItemsCount,
shortDescription: this._shortDescription,
};
if (params.reportUrl) prCommentBody.reportUrl = params.reportUrl;
const commentReq: rp.OptionsWithUri = {
Expand Down

0 comments on commit e9800ac

Please sign in to comment.