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

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 5, 2022
1 parent 162b0f7 commit 1dbe2de
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ jobs:
|:---|:---|:---|
| diff | 差分のあるファイルの結果<br>`SET_ENV_NAME`(default: `GIT_DIFF`) が設定されている場合、その名前で環境変数が設定されます | `src/main.ts src/docs.md` |
| count | 差分のあるファイル数<br>`SET_ENV_NAME_COUNT`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
| insertions | 追加された行数<br>`SET_ENV_NAME_INSERTIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
| deletions | 削除された行数<br>`SET_ENV_NAME_DELETIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
| lines | 追加された行数と削除された行数の和<br>`SET_ENV_NAME_LINES`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `200` |
| insertions | 追加された行数 (`GET_FILE_DIFF` が `true` の場合のみ利用可能)<br>`SET_ENV_NAME_INSERTIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
| deletions | 削除された行数 (`GET_FILE_DIFF` が `true` の場合のみ利用可能)<br>`SET_ENV_NAME_DELETIONS`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `100` |
| lines | 追加された行数と削除された行数の和 (`GET_FILE_DIFF` が `true` の場合のみ利用可能)<br>`SET_ENV_NAME_LINES`(default: `''`) が設定されている場合、その名前で環境変数が設定されます | `200` |

## Action イベント詳細
### 対象イベント
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ If there is no difference in the source code below, this workflow will skip the
|:---|:---|:---|
| 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` |
| 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` |
| 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` |
| 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` |
| 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` |
| 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` |
| 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` |
| 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` |

## Action event details
### Target events
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ inputs:
description: Default value (count).
default: '0'
required: false
GET_FILE_DIFF:
description: Whether to get file diff.
required: false
INSERTIONS_DEFAULT:
description: Default value (insertions).
default: '0'
Expand Down
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
@@ -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"}
{"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"}
28 changes: 20 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,24 @@ const dumpDiffs = (diffs, logger) => {
};
exports.dumpDiffs = dumpDiffs;
const setResult = (diffs, skipped, logger) => {
const insertions = (0, command_1.sumResults)(diffs, item => item.insertions);
const deletions = (0, command_1.sumResults)(diffs, item => item.deletions);
// eslint-disable-next-line no-magic-numbers
const insertions = (0, command_1.sumResults)(diffs, item => 'insertions' in item ? item.insertions : 0);
// eslint-disable-next-line no-magic-numbers
const deletions = (0, command_1.sumResults)(diffs, item => 'deletions' in item ? item.deletions : 0);
const getValue = (setting) => skipped ? (0, core_1.getInput)(`${setting.name.toUpperCase()}_DEFAULT`) : `${setting.value()}`;
const settings = [
{ name: 'diff', value: () => (0, command_1.getDiffFiles)(diffs, false), envNameSuffix: '' },
{ name: 'filtered_diff', value: () => (0, command_1.getDiffFiles)(diffs, true) },
{ name: 'matched_files', value: () => (0, command_1.getMatchedFiles)(diffs) },
{ name: 'count', value: () => diffs.length },
{ name: 'insertions', value: () => insertions },
{ name: 'deletions', value: () => deletions },
{ name: 'lines', value: () => insertions + deletions },
];
if ((0, command_1.getFileDiffFlag)()) {
settings.push(...[
{ name: 'insertions', value: () => insertions },
{ name: 'deletions', value: () => deletions },
{ name: 'lines', value: () => insertions + deletions },
]);
}
logger.startProcess('Dump output');
settings.forEach(setting => {
var _a;
Expand Down Expand Up @@ -144,7 +150,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.sumResults = exports.getMatchedFiles = exports.getDiffFiles = exports.getGitDiff = exports.getFileDiff = void 0;
exports.sumResults = exports.getMatchedFiles = exports.getDiffFiles = exports.getGitDiff = exports.getFileDiff = exports.getFileDiffFlag = void 0;
const path_1 = __nccwpck_require__(1017);
const core_1 = __nccwpck_require__(2186);
const multimatch_1 = __importDefault(__nccwpck_require__(5225));
Expand All @@ -159,6 +165,8 @@ const getFilter = () => (0, core_1.getInput)('DIFF_FILTER', { required: true });
const getRelativePath = () => (0, core_1.getInput)('RELATIVE');
const getOutputFormatType = () => getRawInput('FORMAT');
const escapeWhenJsonFormat = () => github_action_helper_1.Utils.getBoolValue(getRawInput('ESCAPE_JSON'));
const getFileDiffFlag = () => github_action_helper_1.Utils.getBoolValue(getRawInput('GET_FILE_DIFF'));
exports.getFileDiffFlag = getFileDiffFlag;
const getSeparator = () => getRawInput('SEPARATOR');
const getPatterns = () => github_action_helper_1.Utils.getArrayInput('PATTERNS', undefined, '');
const getFiles = () => github_action_helper_1.Utils.getArrayInput('FILES', undefined, '');
Expand All @@ -178,8 +186,11 @@ const getMatchOptions = () => ({
nonegate: github_action_helper_1.Utils.getBoolValue((0, core_1.getInput)('MINIMATCH_OPTION_NONEGATE')),
});
const getCompareRef = (ref) => github_action_helper_1.Utils.isRef(ref) ? github_action_helper_1.Utils.getLocalRefspec(ref, constant_1.REMOTE_NAME) : ref;
const getFileDiff = (file, diffInfo, dot) => __awaiter(void 0, void 0, void 0, function* () {
const getFileDiff = (file, diffInfo, dot, skip) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
if (skip) {
return undefined;
}
const stdout = (yield command.execAsync({
command: 'git diff',
args: [
Expand Down Expand Up @@ -229,6 +240,7 @@ const getGitDiff = (logger, context) => __awaiter(void 0, void 0, void 0, functi
const patterns = getPatterns();
const options = getMatchOptions();
const filter = getFilter();
const skipFileDiff = !(0, exports.getFileDiffFlag)();
return (yield github_action_helper_1.Utils.split((yield command.execAsync({
command: 'git diff',
args: [
Expand All @@ -248,7 +260,7 @@ const getGitDiff = (logger, context) => __awaiter(void 0, void 0, void 0, functi
isMatched: isMatched(item, patterns, options),
}))
.filter(item => item.filterIgnored || item.isMatched)
.map((item) => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign(Object.assign({}, item), yield (0, exports.getFileDiff)(item, diffInfo, dot))); }))
.map((item) => __awaiter(void 0, void 0, void 0, function* () { return (Object.assign(Object.assign({}, item), yield (0, exports.getFileDiff)(item, diffInfo, dot, skipFileDiff))); }))
.reduce((prev, item) => __awaiter(void 0, void 0, void 0, function* () {
const acc = yield prev;
return acc.concat(yield item);
Expand Down

0 comments on commit 1dbe2de

Please sign in to comment.