Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 1dbe2de

Browse files
feat: build for release
1 parent 162b0f7 commit 1dbe2de

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

README.ja.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ jobs:
209209
|:---|:---|:---|
210210
| diff | 差分のあるファイルの結果<br>`SET_ENV_NAME`(default: `GIT_DIFF`) が設定されている場合、その名前で環境変数が設定されます | `src/main.ts src/docs.md` |
211211
| count | 差分のあるファイル数<br>`SET_ENV_NAME_COUNT`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
212-
| insertions | 追加された行数<br>`SET_ENV_NAME_INSERTIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
213-
| deletions | 削除された行数<br>`SET_ENV_NAME_DELETIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
214-
| lines | 追加された行数と削除された行数の和<br>`SET_ENV_NAME_LINES`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `200` |
212+
| insertions | 追加された行数 (`GET_FILE_DIFF``true` の場合のみ利用可能)<br>`SET_ENV_NAME_INSERTIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
213+
| deletions | 削除された行数 (`GET_FILE_DIFF``true` の場合のみ利用可能)<br>`SET_ENV_NAME_DELETIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
214+
| lines | 追加された行数と削除された行数の和 (`GET_FILE_DIFF``true` の場合のみ利用可能)<br>`SET_ENV_NAME_LINES`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `200` |
215215

216216
## Action イベント詳細
217217
### 対象イベント

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ If there is no difference in the source code below, this workflow will skip the
209209
|:---|:---|:---|
210210
| diff | The results of diff file names.<br>If inputs `SET_ENV_NAME`(default: `GIT_DIFF`) is set, an environment variable is set with that name. | `src/main.ts src/docs.md` |
211211
| count | The number of diff files.<br>If inputs `SET_ENV_NAME_COUNT`(default: `''`) is set, an environment variable is set with that name. | `100` |
212-
| insertions | The number of insertions lines.<br>If inputs `SET_ENV_NAME_INSERTIONS`(default: `''`) is set, an environment variable is set with that name. | `100` |
213-
| deletions | The number of deletions lines.<br>If inputs `SET_ENV_NAME_DELETIONS`(default: `''`) is set, an environment variable is set with that name. | `100` |
214-
| lines | The number of diff lines.<br>If inputs `SET_ENV_NAME_LINES`(default: `''`) is set, an environment variable is set with that name. | `200` |
212+
| insertions | The number of insertions lines. (Available only if `GET_FILE_DIFF` is `true`)<br>If inputs `SET_ENV_NAME_INSERTIONS`(default: `''`) is set, an environment variable is set with that name. | `100` |
213+
| deletions | The number of deletions lines. (Available only if `GET_FILE_DIFF` is `true`)<br>If inputs `SET_ENV_NAME_DELETIONS`(default: `''`) is set, an environment variable is set with that name. | `100` |
214+
| lines | The number of diff lines. (Available only if `GET_FILE_DIFF` is `true`)<br>If inputs `SET_ENV_NAME_LINES`(default: `''`) is set, an environment variable is set with that name. | `200` |
215215

216216
## Action event details
217217
### Target events

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ inputs:
105105
description: Default value (count).
106106
default: '0'
107107
required: false
108+
GET_FILE_DIFF:
109+
description: Whether to get file diff.
110+
required: false
108111
INSERTIONS_DEFAULT:
109112
description: Default value (insertions).
110113
default: '0'

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"owner":"technote-space","repo":"get-diff-action","sha":"f6b329f6e5250a5fa5e599a7f9ef0ccec08a5ad4","ref":"refs/tags/test/v5.0.3.1651929536","tagName":"test/v5.0.3.1651929536","branch":"gh-actions","tags":["test/v5.0.3.1651929536","test/v5.0.3","test/v5.0","test/v5"],"updated_at":"2022-01-04T03:04:37.777Z"}
1+
{"owner":"technote-space","repo":"get-diff-action","sha":"FETCH_HEAD","ref":"refs/heads/master","tagName":"test/v5.0.3","branch":"gh-actions","tags":["test/v5.0.3","test/v5.0","test/v5"],"updated_at":"2022-01-05T07:28:59.463Z"}

dist/index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,24 @@ const dumpDiffs = (diffs, logger) => {
9090
};
9191
exports.dumpDiffs = dumpDiffs;
9292
const setResult = (diffs, skipped, logger) => {
93-
const insertions = (0, command_1.sumResults)(diffs, item => item.insertions);
94-
const deletions = (0, command_1.sumResults)(diffs, item => item.deletions);
93+
// eslint-disable-next-line no-magic-numbers
94+
const insertions = (0, command_1.sumResults)(diffs, item => 'insertions' in item ? item.insertions : 0);
95+
// eslint-disable-next-line no-magic-numbers
96+
const deletions = (0, command_1.sumResults)(diffs, item => 'deletions' in item ? item.deletions : 0);
9597
const getValue = (setting) => skipped ? (0, core_1.getInput)(`${setting.name.toUpperCase()}_DEFAULT`) : `${setting.value()}`;
9698
const settings = [
9799
{ name: 'diff', value: () => (0, command_1.getDiffFiles)(diffs, false), envNameSuffix: '' },
98100
{ name: 'filtered_diff', value: () => (0, command_1.getDiffFiles)(diffs, true) },
99101
{ name: 'matched_files', value: () => (0, command_1.getMatchedFiles)(diffs) },
100102
{ name: 'count', value: () => diffs.length },
101-
{ name: 'insertions', value: () => insertions },
102-
{ name: 'deletions', value: () => deletions },
103-
{ name: 'lines', value: () => insertions + deletions },
104103
];
104+
if ((0, command_1.getFileDiffFlag)()) {
105+
settings.push(...[
106+
{ name: 'insertions', value: () => insertions },
107+
{ name: 'deletions', value: () => deletions },
108+
{ name: 'lines', value: () => insertions + deletions },
109+
]);
110+
}
105111
logger.startProcess('Dump output');
106112
settings.forEach(setting => {
107113
var _a;
@@ -144,7 +150,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
144150
return (mod && mod.__esModule) ? mod : { "default": mod };
145151
};
146152
Object.defineProperty(exports, "__esModule", ({ value: true }));
147-
exports.sumResults = exports.getMatchedFiles = exports.getDiffFiles = exports.getGitDiff = exports.getFileDiff = void 0;
153+
exports.sumResults = exports.getMatchedFiles = exports.getDiffFiles = exports.getGitDiff = exports.getFileDiff = exports.getFileDiffFlag = void 0;
148154
const path_1 = __nccwpck_require__(1017);
149155
const core_1 = __nccwpck_require__(2186);
150156
const multimatch_1 = __importDefault(__nccwpck_require__(5225));
@@ -159,6 +165,8 @@ const getFilter = () => (0, core_1.getInput)('DIFF_FILTER', { required: true });
159165
const getRelativePath = () => (0, core_1.getInput)('RELATIVE');
160166
const getOutputFormatType = () => getRawInput('FORMAT');
161167
const escapeWhenJsonFormat = () => github_action_helper_1.Utils.getBoolValue(getRawInput('ESCAPE_JSON'));
168+
const getFileDiffFlag = () => github_action_helper_1.Utils.getBoolValue(getRawInput('GET_FILE_DIFF'));
169+
exports.getFileDiffFlag = getFileDiffFlag;
162170
const getSeparator = () => getRawInput('SEPARATOR');
163171
const getPatterns = () => github_action_helper_1.Utils.getArrayInput('PATTERNS', undefined, '');
164172
const getFiles = () => github_action_helper_1.Utils.getArrayInput('FILES', undefined, '');
@@ -178,8 +186,11 @@ const getMatchOptions = () => ({
178186
nonegate: github_action_helper_1.Utils.getBoolValue((0, core_1.getInput)('MINIMATCH_OPTION_NONEGATE')),
179187
});
180188
const getCompareRef = (ref) => github_action_helper_1.Utils.isRef(ref) ? github_action_helper_1.Utils.getLocalRefspec(ref, constant_1.REMOTE_NAME) : ref;
181-
const getFileDiff = (file, diffInfo, dot) => __awaiter(void 0, void 0, void 0, function* () {
189+
const getFileDiff = (file, diffInfo, dot, skip) => __awaiter(void 0, void 0, void 0, function* () {
182190
var _a, _b;
191+
if (skip) {
192+
return undefined;
193+
}
183194
const stdout = (yield command.execAsync({
184195
command: 'git diff',
185196
args: [
@@ -229,6 +240,7 @@ const getGitDiff = (logger, context) => __awaiter(void 0, void 0, void 0, functi
229240
const patterns = getPatterns();
230241
const options = getMatchOptions();
231242
const filter = getFilter();
243+
const skipFileDiff = !(0, exports.getFileDiffFlag)();
232244
return (yield github_action_helper_1.Utils.split((yield command.execAsync({
233245
command: 'git diff',
234246
args: [
@@ -248,7 +260,7 @@ const getGitDiff = (logger, context) => __awaiter(void 0, void 0, void 0, functi
248260
isMatched: isMatched(item, patterns, options),
249261
}))
250262
.filter(item => item.filterIgnored || item.isMatched)
251-
.map((item) => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign(Object.assign({}, item), yield (0, exports.getFileDiff)(item, diffInfo, dot))); }))
263+
.map((item) => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign(Object.assign({}, item), yield (0, exports.getFileDiff)(item, diffInfo, dot, skipFileDiff))); }))
252264
.reduce((prev, item) => __awaiter(void 0, void 0, void 0, function* () {
253265
const acc = yield prev;
254266
return acc.concat(yield item);

0 commit comments

Comments
 (0)