Skip to content

Commit 05165c6

Browse files
committed
feature: @putout/plugin-github: set-message-of-commit-fixes
1 parent 6319d79 commit 05165c6

File tree

9 files changed

+165
-0
lines changed

9 files changed

+165
-0
lines changed

packages/plugin-github/README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ npm i @putout/plugin-github -D
2424
-[insert-rust](#insert-rust);
2525
-[install-bun](#install-bun);
2626
-[set-node-versions](#set-node-versions);
27+
-[set-message-of-commit-fixes](#set-message-of-commit-fixes);
2728
-[update-actions](#update-actions);
2829

2930
## Config
@@ -34,6 +35,7 @@ npm i @putout/plugin-github -D
3435
"github/add-continue-on-error-to-coveralls": "on",
3536
"github/add-continue-on-error-to-add-and-commit": "on",
3637
"github/set-node-versions": "on",
38+
"github/set-message-of-commit-fixes": "on",
3739
"github/install-bun": "on",
3840
"github/install-rust": "on",
3941
"github/convert-npm-to-bun": "on",
@@ -69,6 +71,30 @@ Add ability to continue when cannot submit coverage to Coveralls using [`continu
6971
+ continue-on-error: true
7072
```
7173

74+
## set-message-of-commit-fixes
75+
76+
Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0379415220b31bbbab2d29c155b5b7eb/08839962bed379f7169e05a30ae5e082d9731c75).
77+
78+
```diff
79+
uses: EndBug/add-and-commit@v9
80+
continue-on-error: true
81+
with:
82+
- message: chore(${{ env.NAME }}) lint using actions
83+
+ message: "chore: ${{ env.NAME }}: actions: lint ☘️"
84+
```
85+
86+
You can override message with:
87+
88+
```json
89+
{
90+
"rules": {
91+
"github/set-message-of-commit-fixes": ["on", {
92+
"message": "✅ fixed with github actions"
93+
}]
94+
}
95+
}
96+
```
97+
7298
## set-node-versions
7399

74100
```diff

packages/plugin-github/lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as setMessageOfCommitFixes from './set-message-of-commit-fixes/index.js';
12
import * as insertRust from './insert-rust/index.js';
23
import * as convertNpmToBun from './convert-npm-to-bun/index.js';
34
import * as installBun from './install-bun/index.js';
@@ -14,4 +15,5 @@ export const rules = {
1415
'install-bun': installBun,
1516
'convert-npm-to-bun': convertNpmToBun,
1617
'insert-rust': insertRust,
18+
'set-message-of-commit-fixes': setMessageOfCommitFixes,
1719
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
__putout_processor_yaml({
2+
"name": "Node CI",
3+
"on": ["push", "pull_request"],
4+
"jobs": {
5+
"build": {
6+
"steps": [{
7+
"name": "Commit fixes",
8+
"uses": "EndBug/add-and-commit@v9",
9+
"continue-on-error": true,
10+
"with": {
11+
"message": "chore: ${{ env.NAME }}: actions: lint ☘️"
12+
}
13+
}]
14+
}
15+
}
16+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
__putout_processor_yaml({
2+
"name": "Node CI",
3+
"on": [
4+
"push",
5+
"pull_request"
6+
],
7+
"jobs": {
8+
"build": {
9+
"steps": [
10+
{
11+
"name": "Commit fixes",
12+
"uses": "EndBug/add-and-commit@v9",
13+
"continue-on-error": true,
14+
"with": {
15+
"message": "chore(${{ env.NAME }}) lint using actions"
16+
}
17+
},
18+
]
19+
}
20+
}
21+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {operator} from 'putout';
2+
3+
const {
4+
traverseProperties,
5+
getTemplateValues,
6+
__yaml,
7+
setLiteralValue,
8+
} = operator;
9+
10+
export const report = () => `Set 'message' of 'Commit fixes'`;
11+
12+
export const fix = ({path, message}) => {
13+
setLiteralValue(path, message);
14+
};
15+
16+
export const traverse = ({push, options}) => ({
17+
[__yaml](path) {
18+
const {message = 'chore: ${{ env.NAME }}: actions: lint ☘️'} = options;
19+
20+
const {__object} = getTemplateValues(path, __yaml);
21+
22+
for (const messagePath of traverseProperties(__object, 'message')) {
23+
const valuePath = messagePath.get('value');
24+
const {value} = valuePath.node;
25+
26+
if (value === message)
27+
break;
28+
29+
push({
30+
path: valuePath,
31+
message,
32+
});
33+
}
34+
},
35+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {createTest} from '@putout/test';
2+
import * as plugin from './index.js';
3+
4+
const test = createTest(import.meta.url, {
5+
plugins: [
6+
['set-message-of-commit-fixes', plugin],
7+
],
8+
});
9+
10+
test('github: set-message-of-commit-fixes: report', (t) => {
11+
t.report('set-message-of-commit-fixes', `Set 'message' of 'Commit fixes'`);
12+
t.end();
13+
});
14+
15+
test('github: set-message-of-commit-fixes: no report after transform', (t) => {
16+
t.noReportAfterTransform('set-message-of-commit-fixes');
17+
t.end();
18+
});
19+
20+
test('github: set-message-of-commit-fixes: transform', (t) => {
21+
t.transform('set-message-of-commit-fixes');
22+
t.end();
23+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
__putout_processor_yaml({
2+
"name": "Node CI",
3+
"on": ["push", "pull_request"],
4+
"jobs": {
5+
"build": {
6+
"steps": [{
7+
"name": "Commit fixes",
8+
"uses": "EndBug/add-and-commit@v9",
9+
"continue-on-error": true,
10+
"with": {
11+
"message": "chore: ${{ env.NAME }}: actions: lint ☘️"
12+
}
13+
}]
14+
}
15+
}
16+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
__putout_processor_yaml({
2+
"name": "Node CI",
3+
"on": [
4+
"push",
5+
"pull_request"
6+
],
7+
"jobs": {
8+
"build": {
9+
"steps": [
10+
{
11+
"name": "Commit fixes",
12+
"uses": "EndBug/add-and-commit@v9",
13+
"continue-on-error": true,
14+
"with": {
15+
"message": "chore(${{ env.NAME }}) lint using actions"
16+
}
17+
},
18+
]
19+
}
20+
}
21+
});

packages/plugin-github/test/github.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,8 @@ test('plugin-github: transform: set-docker-setup-buildx-version', (t) => {
7171
t.transform('set-docker-setup-buildx-version');
7272
t.end();
7373
});
74+
75+
test('plugin-github: transform: set-message-of-commit-fixes', (t) => {
76+
t.transform('set-message-of-commit-fixes');
77+
t.end();
78+
});

0 commit comments

Comments
 (0)