intershell 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +301 -0
- package/dist/commands/ci/act.d.ts +13 -0
- package/dist/commands/ci/act.d.ts.map +1 -0
- package/dist/commands/ci/act.js +89 -0
- package/dist/commands/ci/act.js.map +1 -0
- package/dist/commands/ci/attach-affected.d.ts +12 -0
- package/dist/commands/ci/attach-affected.d.ts.map +1 -0
- package/dist/commands/ci/attach-affected.js +83 -0
- package/dist/commands/ci/attach-affected.js.map +1 -0
- package/dist/commands/ci/attach-service-ports.d.ts +10 -0
- package/dist/commands/ci/attach-service-ports.d.ts.map +1 -0
- package/dist/commands/ci/attach-service-ports.js +25 -0
- package/dist/commands/ci/attach-service-ports.js.map +1 -0
- package/dist/commands/commit-check.d.ts +13 -0
- package/dist/commands/commit-check.d.ts.map +1 -0
- package/dist/commands/commit-check.js +110 -0
- package/dist/commands/commit-check.js.map +1 -0
- package/dist/commands/commit.d.ts +16 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +91 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/dev/check.d.ts +13 -0
- package/dist/commands/dev/check.d.ts.map +1 -0
- package/dist/commands/dev/check.js +91 -0
- package/dist/commands/dev/check.js.map +1 -0
- package/dist/commands/dev/cleanup.d.ts +10 -0
- package/dist/commands/dev/cleanup.d.ts.map +1 -0
- package/dist/commands/dev/cleanup.js +28 -0
- package/dist/commands/dev/cleanup.js.map +1 -0
- package/dist/commands/dev/rm.d.ts +12 -0
- package/dist/commands/dev/rm.d.ts.map +1 -0
- package/dist/commands/dev/rm.js +49 -0
- package/dist/commands/dev/rm.js.map +1 -0
- package/dist/commands/dev/setup.d.ts +10 -0
- package/dist/commands/dev/setup.d.ts.map +1 -0
- package/dist/commands/dev/setup.js +40 -0
- package/dist/commands/dev/setup.js.map +1 -0
- package/dist/commands/local/cleanup.d.ts +12 -0
- package/dist/commands/local/cleanup.d.ts.map +1 -0
- package/dist/commands/local/cleanup.js +62 -0
- package/dist/commands/local/cleanup.js.map +1 -0
- package/dist/commands/local/setup.d.ts +11 -0
- package/dist/commands/local/setup.d.ts.map +1 -0
- package/dist/commands/local/setup.js +55 -0
- package/dist/commands/local/setup.js.map +1 -0
- package/dist/commands/local/vscode.d.ts +17 -0
- package/dist/commands/local/vscode.d.ts.map +1 -0
- package/dist/commands/local/vscode.js +94 -0
- package/dist/commands/local/vscode.js.map +1 -0
- package/dist/commands/update-package-json.d.ts +12 -0
- package/dist/commands/update-package-json.d.ts.map +1 -0
- package/dist/commands/update-package-json.js +82 -0
- package/dist/commands/update-package-json.js.map +1 -0
- package/dist/commands/version/apply.d.ts +16 -0
- package/dist/commands/version/apply.d.ts.map +1 -0
- package/dist/commands/version/apply.js +120 -0
- package/dist/commands/version/apply.js.map +1 -0
- package/dist/commands/version/ci.d.ts +12 -0
- package/dist/commands/version/ci.d.ts.map +1 -0
- package/dist/commands/version/ci.js +67 -0
- package/dist/commands/version/ci.js.map +1 -0
- package/dist/commands/version/prepare.d.ts +19 -0
- package/dist/commands/version/prepare.d.ts.map +1 -0
- package/dist/commands/version/prepare.js +153 -0
- package/dist/commands/version/prepare.js.map +1 -0
- package/dist/core/colorify.d.ts +21 -0
- package/dist/core/colorify.d.ts.map +1 -0
- package/dist/core/colorify.js +56 -0
- package/dist/core/colorify.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +181 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wrapshell.d.ts +19 -0
- package/dist/core/wrapshell.d.ts.map +1 -0
- package/dist/core/wrapshell.js +323 -0
- package/dist/core/wrapshell.js.map +1 -0
- package/dist/entities/affected/affected.d.ts +4 -0
- package/dist/entities/affected/affected.d.ts.map +1 -0
- package/dist/entities/affected/affected.js +20 -0
- package/dist/entities/affected/affected.js.map +1 -0
- package/dist/entities/affected/affected.test.d.ts +2 -0
- package/dist/entities/affected/affected.test.d.ts.map +1 -0
- package/dist/entities/affected/affected.test.js +305 -0
- package/dist/entities/affected/affected.test.js.map +1 -0
- package/dist/entities/affected/index.d.ts +2 -0
- package/dist/entities/affected/index.d.ts.map +1 -0
- package/dist/entities/affected/index.js +2 -0
- package/dist/entities/affected/index.js.map +1 -0
- package/dist/entities/branch/branch.d.ts +8 -0
- package/dist/entities/branch/branch.d.ts.map +1 -0
- package/dist/entities/branch/branch.js +74 -0
- package/dist/entities/branch/branch.js.map +1 -0
- package/dist/entities/branch/branch.test.d.ts +2 -0
- package/dist/entities/branch/branch.test.d.ts.map +1 -0
- package/dist/entities/branch/branch.test.js +316 -0
- package/dist/entities/branch/branch.test.js.map +1 -0
- package/dist/entities/branch/branch.types.d.ts +6 -0
- package/dist/entities/branch/branch.types.d.ts.map +1 -0
- package/dist/entities/branch/branch.types.js +2 -0
- package/dist/entities/branch/branch.types.js.map +1 -0
- package/dist/entities/branch/index.d.ts +3 -0
- package/dist/entities/branch/index.d.ts.map +1 -0
- package/dist/entities/branch/index.js +3 -0
- package/dist/entities/branch/index.js.map +1 -0
- package/dist/entities/commit/commit.d.ts +15 -0
- package/dist/entities/commit/commit.d.ts.map +1 -0
- package/dist/entities/commit/commit.js +196 -0
- package/dist/entities/commit/commit.js.map +1 -0
- package/dist/entities/commit/commit.test.d.ts +26 -0
- package/dist/entities/commit/commit.test.d.ts.map +1 -0
- package/dist/entities/commit/commit.test.js +550 -0
- package/dist/entities/commit/commit.test.js.map +1 -0
- package/dist/entities/commit/commit.types.d.ts +49 -0
- package/dist/entities/commit/commit.types.d.ts.map +1 -0
- package/dist/entities/commit/commit.types.js +31 -0
- package/dist/entities/commit/commit.types.js.map +1 -0
- package/dist/entities/commit/index.d.ts +3 -0
- package/dist/entities/commit/index.d.ts.map +1 -0
- package/dist/entities/commit/index.js +3 -0
- package/dist/entities/commit/index.js.map +1 -0
- package/dist/entities/commit/pr.d.ts +11 -0
- package/dist/entities/commit/pr.d.ts.map +1 -0
- package/dist/entities/commit/pr.js +201 -0
- package/dist/entities/commit/pr.js.map +1 -0
- package/dist/entities/commit/pr.test.d.ts +2 -0
- package/dist/entities/commit/pr.test.d.ts.map +1 -0
- package/dist/entities/commit/pr.test.js +782 -0
- package/dist/entities/commit/pr.test.js.map +1 -0
- package/dist/entities/compose/compose.d.ts +18 -0
- package/dist/entities/compose/compose.d.ts.map +1 -0
- package/dist/entities/compose/compose.js +197 -0
- package/dist/entities/compose/compose.js.map +1 -0
- package/dist/entities/compose/compose.test.d.ts +2 -0
- package/dist/entities/compose/compose.test.d.ts.map +1 -0
- package/dist/entities/compose/compose.test.js +406 -0
- package/dist/entities/compose/compose.test.js.map +1 -0
- package/dist/entities/compose/compose.types.d.ts +77 -0
- package/dist/entities/compose/compose.types.d.ts.map +1 -0
- package/dist/entities/compose/compose.types.js +2 -0
- package/dist/entities/compose/compose.types.js.map +1 -0
- package/dist/entities/compose/index.d.ts +3 -0
- package/dist/entities/compose/index.d.ts.map +1 -0
- package/dist/entities/compose/index.js +3 -0
- package/dist/entities/compose/index.js.map +1 -0
- package/dist/entities/entities.shell.d.ts +29 -0
- package/dist/entities/entities.shell.d.ts.map +1 -0
- package/dist/entities/entities.shell.js +27 -0
- package/dist/entities/entities.shell.js.map +1 -0
- package/dist/entities/entities.shell.test.d.ts +2 -0
- package/dist/entities/entities.shell.test.d.ts.map +1 -0
- package/dist/entities/entities.shell.test.js +23 -0
- package/dist/entities/entities.shell.test.js.map +1 -0
- package/dist/entities/index.d.ts +12 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +12 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.d.ts +11 -0
- package/dist/entities/intershell-config/intershell-config.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts +188 -0
- package/dist/entities/intershell-config/intershell-config.default.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.default.js +225 -0
- package/dist/entities/intershell-config/intershell-config.default.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.js +132 -0
- package/dist/entities/intershell-config/intershell-config.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts +2 -0
- package/dist/entities/intershell-config/intershell-config.test.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.test.js +102 -0
- package/dist/entities/intershell-config/intershell-config.test.js.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts +103 -0
- package/dist/entities/intershell-config/intershell-config.types.d.ts.map +1 -0
- package/dist/entities/intershell-config/intershell-config.types.js +2 -0
- package/dist/entities/intershell-config/intershell-config.types.js.map +1 -0
- package/dist/entities/package/index.d.ts +4 -0
- package/dist/entities/package/index.d.ts.map +1 -0
- package/dist/entities/package/index.js +4 -0
- package/dist/entities/package/index.js.map +1 -0
- package/dist/entities/package/package.d.ts +49 -0
- package/dist/entities/package/package.d.ts.map +1 -0
- package/dist/entities/package/package.js +234 -0
- package/dist/entities/package/package.js.map +1 -0
- package/dist/entities/package/package.shell.d.ts +48 -0
- package/dist/entities/package/package.shell.d.ts.map +1 -0
- package/dist/entities/package/package.shell.js +118 -0
- package/dist/entities/package/package.shell.js.map +1 -0
- package/dist/entities/package/package.test.d.ts +23 -0
- package/dist/entities/package/package.test.d.ts.map +1 -0
- package/dist/entities/package/package.test.js +637 -0
- package/dist/entities/package/package.test.js.map +1 -0
- package/dist/entities/package/package.types.d.ts +48 -0
- package/dist/entities/package/package.types.d.ts.map +1 -0
- package/dist/entities/package/package.types.js +2 -0
- package/dist/entities/package/package.types.js.map +1 -0
- package/dist/entities/package-changelog/index.d.ts +4 -0
- package/dist/entities/package-changelog/index.d.ts.map +1 -0
- package/dist/entities/package-changelog/index.js +4 -0
- package/dist/entities/package-changelog/index.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.d.ts +20 -0
- package/dist/entities/package-changelog/package-changelog.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.js +59 -0
- package/dist/entities/package-changelog/package-changelog.js.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts +25 -0
- package/dist/entities/package-changelog/package-changelog.types.d.ts.map +1 -0
- package/dist/entities/package-changelog/package-changelog.types.js +2 -0
- package/dist/entities/package-changelog/package-changelog.types.js.map +1 -0
- package/dist/entities/package-changelog/template.d.ts +20 -0
- package/dist/entities/package-changelog/template.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.d.ts +10 -0
- package/dist/entities/package-changelog/template.default.d.ts.map +1 -0
- package/dist/entities/package-changelog/template.default.js +85 -0
- package/dist/entities/package-changelog/template.default.js.map +1 -0
- package/dist/entities/package-changelog/template.js +90 -0
- package/dist/entities/package-changelog/template.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts +35 -0
- package/dist/entities/package-commits/dependency-analyzer.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.js +169 -0
- package/dist/entities/package-commits/dependency-analyzer.js.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts +2 -0
- package/dist/entities/package-commits/dependency-analyzer.test.d.ts.map +1 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js +25 -0
- package/dist/entities/package-commits/dependency-analyzer.test.js.map +1 -0
- package/dist/entities/package-commits/index.d.ts +3 -0
- package/dist/entities/package-commits/index.d.ts.map +1 -0
- package/dist/entities/package-commits/index.js +3 -0
- package/dist/entities/package-commits/index.js.map +1 -0
- package/dist/entities/package-commits/package-commits.d.ts +33 -0
- package/dist/entities/package-commits/package-commits.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.js +149 -0
- package/dist/entities/package-commits/package-commits.js.map +1 -0
- package/dist/entities/package-commits/package-commits.test.d.ts +2 -0
- package/dist/entities/package-commits/package-commits.test.d.ts.map +1 -0
- package/dist/entities/package-commits/package-commits.test.js +40 -0
- package/dist/entities/package-commits/package-commits.test.js.map +1 -0
- package/dist/entities/package-tags/index.d.ts +2 -0
- package/dist/entities/package-tags/index.d.ts.map +1 -0
- package/dist/entities/package-tags/index.js +2 -0
- package/dist/entities/package-tags/index.js.map +1 -0
- package/dist/entities/package-tags/package-tags.d.ts +24 -0
- package/dist/entities/package-tags/package-tags.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.js +197 -0
- package/dist/entities/package-tags/package-tags.js.map +1 -0
- package/dist/entities/package-tags/package-tags.test.d.ts +2 -0
- package/dist/entities/package-tags/package-tags.test.d.ts.map +1 -0
- package/dist/entities/package-tags/package-tags.test.js +60 -0
- package/dist/entities/package-tags/package-tags.test.js.map +1 -0
- package/dist/entities/package-version/index.d.ts +3 -0
- package/dist/entities/package-version/index.d.ts.map +1 -0
- package/dist/entities/package-version/index.js +3 -0
- package/dist/entities/package-version/index.js.map +1 -0
- package/dist/entities/package-version/package-version.d.ts +16 -0
- package/dist/entities/package-version/package-version.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.js +166 -0
- package/dist/entities/package-version/package-version.js.map +1 -0
- package/dist/entities/package-version/package-version.test.d.ts +2 -0
- package/dist/entities/package-version/package-version.test.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.test.js +113 -0
- package/dist/entities/package-version/package-version.test.js.map +1 -0
- package/dist/entities/package-version/package-version.types.d.ts +31 -0
- package/dist/entities/package-version/package-version.types.d.ts.map +1 -0
- package/dist/entities/package-version/package-version.types.js +2 -0
- package/dist/entities/package-version/package-version.types.js.map +1 -0
- package/dist/entities/tag/index.d.ts +3 -0
- package/dist/entities/tag/index.d.ts.map +1 -0
- package/dist/entities/tag/index.js +3 -0
- package/dist/entities/tag/index.js.map +1 -0
- package/dist/entities/tag/tag.d.ts +24 -0
- package/dist/entities/tag/tag.d.ts.map +1 -0
- package/dist/entities/tag/tag.js +168 -0
- package/dist/entities/tag/tag.js.map +1 -0
- package/dist/entities/tag/tag.test.d.ts +2 -0
- package/dist/entities/tag/tag.test.d.ts.map +1 -0
- package/dist/entities/tag/tag.test.js +638 -0
- package/dist/entities/tag/tag.test.js.map +1 -0
- package/dist/entities/tag/tag.types.d.ts +35 -0
- package/dist/entities/tag/tag.types.d.ts.map +1 -0
- package/dist/entities/tag/tag.types.js +2 -0
- package/dist/entities/tag/tag.types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -0
- package/src/commands/ci/act.ts +95 -0
- package/src/commands/ci/attach-affected.ts +93 -0
- package/src/commands/ci/attach-service-ports.ts +31 -0
- package/src/commands/commit-check.ts +124 -0
- package/src/commands/commit.ts +103 -0
- package/src/commands/dev/check.ts +117 -0
- package/src/commands/dev/cleanup.ts +34 -0
- package/src/commands/dev/rm.ts +66 -0
- package/src/commands/dev/setup.ts +48 -0
- package/src/commands/local/cleanup.ts +74 -0
- package/src/commands/local/setup.ts +68 -0
- package/src/commands/local/vscode.ts +118 -0
- package/src/commands/update-package-json.ts +104 -0
- package/src/commands/version/apply.ts +156 -0
- package/src/commands/version/ci.ts +85 -0
- package/src/commands/version/prepare.ts +217 -0
- package/src/core/colorify.ts +61 -0
- package/src/core/index.ts +3 -0
- package/src/core/types.ts +262 -0
- package/src/core/wrapshell.ts +388 -0
- package/src/entities/affected/affected.test.ts +427 -0
- package/src/entities/affected/affected.ts +22 -0
- package/src/entities/affected/index.ts +1 -0
- package/src/entities/branch/branch.test.ts +348 -0
- package/src/entities/branch/branch.ts +89 -0
- package/src/entities/branch/branch.types.ts +5 -0
- package/src/entities/branch/index.ts +2 -0
- package/src/entities/commit/commit.test.ts +769 -0
- package/src/entities/commit/commit.ts +245 -0
- package/src/entities/commit/commit.types.ts +81 -0
- package/src/entities/commit/index.ts +2 -0
- package/src/entities/commit/pr.test.ts +860 -0
- package/src/entities/commit/pr.ts +241 -0
- package/src/entities/compose/compose.test.ts +496 -0
- package/src/entities/compose/compose.ts +251 -0
- package/src/entities/compose/compose.types.ts +88 -0
- package/src/entities/compose/index.ts +2 -0
- package/src/entities/entities.shell.test.ts +35 -0
- package/src/entities/entities.shell.ts +81 -0
- package/src/entities/index.ts +11 -0
- package/src/entities/intershell-config/intershell-config.default.ts +229 -0
- package/src/entities/intershell-config/intershell-config.test.ts +117 -0
- package/src/entities/intershell-config/intershell-config.ts +143 -0
- package/src/entities/intershell-config/intershell-config.types.ts +118 -0
- package/src/entities/package/index.ts +3 -0
- package/src/entities/package/package.shell.ts +124 -0
- package/src/entities/package/package.test.ts +830 -0
- package/src/entities/package/package.ts +267 -0
- package/src/entities/package/package.types.ts +49 -0
- package/src/entities/package-changelog/index.ts +3 -0
- package/src/entities/package-changelog/package-changelog.ts +81 -0
- package/src/entities/package-changelog/package-changelog.types.ts +30 -0
- package/src/entities/package-changelog/template.default.ts +109 -0
- package/src/entities/package-changelog/template.ts +118 -0
- package/src/entities/package-commits/dependency-analyzer.test.ts +29 -0
- package/src/entities/package-commits/dependency-analyzer.ts +194 -0
- package/src/entities/package-commits/index.ts +2 -0
- package/src/entities/package-commits/package-commits.test.ts +44 -0
- package/src/entities/package-commits/package-commits.ts +191 -0
- package/src/entities/package-tags/index.ts +1 -0
- package/src/entities/package-tags/package-tags.test.ts +73 -0
- package/src/entities/package-tags/package-tags.ts +234 -0
- package/src/entities/package-version/index.ts +2 -0
- package/src/entities/package-version/package-version.test.ts +141 -0
- package/src/entities/package-version/package-version.ts +234 -0
- package/src/entities/package-version/package-version.types.ts +35 -0
- package/src/entities/tag/index.ts +2 -0
- package/src/entities/tag/tag.test.ts +844 -0
- package/src/entities/tag/tag.ts +208 -0
- package/src/entities/tag/tag.types.ts +37 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { EntityBranch, type ParsedBranch } from "../branch";
|
|
2
|
+
import { entitiesShell } from "../entities.shell";
|
|
3
|
+
import type { IConfig, PRCategory } from "../intershell-config/intershell-config.types";
|
|
4
|
+
import type { ParsedCommitData, PRStats } from "./commit.types";
|
|
5
|
+
|
|
6
|
+
export class EntityPr {
|
|
7
|
+
private readonly defaultBranch: string | undefined;
|
|
8
|
+
constructor(readonly config: IConfig) {
|
|
9
|
+
this.defaultBranch = config?.branch?.defaultBranch;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getPRInfo(
|
|
13
|
+
parseByHash: (hash: string) => Promise<ParsedCommitData>,
|
|
14
|
+
hash: string,
|
|
15
|
+
message: ParsedCommitData["message"],
|
|
16
|
+
): Promise<ParsedCommitData["pr"]> {
|
|
17
|
+
try {
|
|
18
|
+
const prNumber = extractPRNumber(message);
|
|
19
|
+
|
|
20
|
+
if (!prNumber) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const prCommits = await getPRCommits(hash, parseByHash);
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
prNumber: extractPRNumber(message) || "",
|
|
28
|
+
prCategory: categorizePR(prCommits, message),
|
|
29
|
+
prStats: getPRStats(prCommits),
|
|
30
|
+
prCommits: prCommits.length > 0 ? prCommits : [],
|
|
31
|
+
prBranchName: this.getPrBranch({ message }),
|
|
32
|
+
};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.warn(`Failed to get PR info for commit ${hash}: ${error}`);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public getPrBranch({ message }: ParsedCommitData): ParsedBranch {
|
|
40
|
+
if (!message.isMerge) {
|
|
41
|
+
return {
|
|
42
|
+
name: this.defaultBranch || "",
|
|
43
|
+
fullName: this.defaultBranch || "",
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const mainMessage = message.bodyLines?.join("\n") || "";
|
|
48
|
+
if (!mainMessage.includes("from ")) {
|
|
49
|
+
return {
|
|
50
|
+
name: this.defaultBranch || "",
|
|
51
|
+
fullName: this.defaultBranch || "",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const fromIndex = mainMessage.indexOf("from ");
|
|
56
|
+
const afterFrom = mainMessage.substring(fromIndex + 5);
|
|
57
|
+
let firstLine = afterFrom.split("\n")[0].trim();
|
|
58
|
+
const originalFullName = firstLine; // Store the original full name
|
|
59
|
+
|
|
60
|
+
if (firstLine.includes(":")) {
|
|
61
|
+
firstLine = firstLine.split(":").reverse()[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Use the centralized EntityBranch parsing logic
|
|
65
|
+
const branchInstance = new EntityBranch();
|
|
66
|
+
const parsed = branchInstance.parseByName(firstLine);
|
|
67
|
+
|
|
68
|
+
// Return the parsed branch with the original full name
|
|
69
|
+
return {
|
|
70
|
+
name: parsed.name,
|
|
71
|
+
fullName: originalFullName, // Keep the original full name from the commit
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function extractPRNumber(mergeMessage: ParsedCommitData["message"]): string | undefined {
|
|
77
|
+
// Try different merge commit patterns
|
|
78
|
+
const patterns = [
|
|
79
|
+
/Merge pull request #(\d+)/, // "Merge pull request #123"
|
|
80
|
+
/Merge PR #(\d+)/, // "Merge PR #123"
|
|
81
|
+
/Merge.*#(\d+)/, // "Merge branch 'feature' into main #123"
|
|
82
|
+
/#(\d+)/, // Any message containing #123 (secure pattern)
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
for (const pattern of patterns) {
|
|
86
|
+
const match = mergeMessage.description.match(pattern);
|
|
87
|
+
if (match) {
|
|
88
|
+
return match[1];
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
async function getPRCommits(
|
|
96
|
+
mergeCommitHash: string,
|
|
97
|
+
parseByHash: (hash: string) => Promise<ParsedCommitData>,
|
|
98
|
+
): Promise<ParsedCommitData[]> {
|
|
99
|
+
try {
|
|
100
|
+
// First, try the regular merge approach
|
|
101
|
+
const result = await entitiesShell.gitLogHashes([`${mergeCommitHash}^..${mergeCommitHash}^2`]);
|
|
102
|
+
|
|
103
|
+
if (result.exitCode === 0) {
|
|
104
|
+
const commitHashes = result.text().trim().split("\n").filter(Boolean);
|
|
105
|
+
|
|
106
|
+
// If we found multiple commits, this is a regular merge
|
|
107
|
+
if (commitHashes.length > 1) {
|
|
108
|
+
const prCommits = await Promise.all(
|
|
109
|
+
commitHashes.map(async (hash) => {
|
|
110
|
+
try {
|
|
111
|
+
return await parseByHash(hash);
|
|
112
|
+
} catch (error) {
|
|
113
|
+
console.warn(`Failed to parse PR commit ${hash}: ${error}`);
|
|
114
|
+
// Fallback to basic info if parsing fails
|
|
115
|
+
return {
|
|
116
|
+
message: {
|
|
117
|
+
type: "other",
|
|
118
|
+
description: "Failed to parse commit",
|
|
119
|
+
isMerge: false,
|
|
120
|
+
isDependency: false,
|
|
121
|
+
isBreaking: false,
|
|
122
|
+
},
|
|
123
|
+
info: {
|
|
124
|
+
hash: hash.trim(),
|
|
125
|
+
},
|
|
126
|
+
} as ParsedCommitData;
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const validCommits = prCommits.filter(
|
|
132
|
+
(commit) => commit.info?.hash && commit.message.description,
|
|
133
|
+
);
|
|
134
|
+
return validCommits;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// If we only found 1 commit, this might be a squash merge
|
|
138
|
+
// For squash merges, we can't recover individual commits from git history
|
|
139
|
+
// But we can create a synthetic commit representing the squashed changes
|
|
140
|
+
if (commitHashes.length === 1) {
|
|
141
|
+
const squashedHash = commitHashes[0];
|
|
142
|
+
try {
|
|
143
|
+
const squashedCommit = await parseByHash(squashedHash);
|
|
144
|
+
// Mark this as a squashed commit so the changelog can handle it appropriately
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
...squashedCommit,
|
|
148
|
+
message: {
|
|
149
|
+
...squashedCommit.message,
|
|
150
|
+
description: `Squashed changes from PR (${squashedCommit.message.description})`,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.warn(`Failed to parse squashed commit ${squashedHash}: ${error}`);
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Fallback: return empty array if no commits found
|
|
162
|
+
return [];
|
|
163
|
+
} catch (_error) {
|
|
164
|
+
return [];
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function categorizePR(
|
|
169
|
+
prCommits: ParsedCommitData[],
|
|
170
|
+
mergeMessage: ParsedCommitData["message"],
|
|
171
|
+
): PRCategory {
|
|
172
|
+
if (
|
|
173
|
+
mergeMessage.description.includes("renovate") ||
|
|
174
|
+
mergeMessage.description.includes("dependabot") ||
|
|
175
|
+
mergeMessage.bodyLines.some((line) => line.toLowerCase().includes("dependency"))
|
|
176
|
+
) {
|
|
177
|
+
return "dependencies";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const scores = {
|
|
181
|
+
features: 0,
|
|
182
|
+
bugfixes: 0,
|
|
183
|
+
dependencies: 0,
|
|
184
|
+
infrastructure: 0,
|
|
185
|
+
documentation: 0,
|
|
186
|
+
refactoring: 0,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
for (const commit of prCommits) {
|
|
190
|
+
const commitType = commit.message.type;
|
|
191
|
+
|
|
192
|
+
switch (commitType) {
|
|
193
|
+
case "feat":
|
|
194
|
+
scores.features += 3;
|
|
195
|
+
break;
|
|
196
|
+
case "fix":
|
|
197
|
+
scores.bugfixes += 2;
|
|
198
|
+
break;
|
|
199
|
+
case "deps":
|
|
200
|
+
case "chore":
|
|
201
|
+
if (
|
|
202
|
+
commit.message.description.includes("dep") ||
|
|
203
|
+
commit.message.description.includes("update") ||
|
|
204
|
+
commit.message.description.includes("upgrade")
|
|
205
|
+
) {
|
|
206
|
+
scores.dependencies += 5;
|
|
207
|
+
} else if (
|
|
208
|
+
commit.message.description.includes("ci") ||
|
|
209
|
+
commit.message.description.includes("build") ||
|
|
210
|
+
commit.message.description.includes("workflow")
|
|
211
|
+
) {
|
|
212
|
+
scores.infrastructure += 2;
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
case "docs":
|
|
216
|
+
scores.documentation += 2;
|
|
217
|
+
break;
|
|
218
|
+
case "refactor":
|
|
219
|
+
case "style":
|
|
220
|
+
case "perf":
|
|
221
|
+
scores.refactoring += 2;
|
|
222
|
+
break;
|
|
223
|
+
case "ci":
|
|
224
|
+
case "build":
|
|
225
|
+
scores.infrastructure += 3;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const maxScore = Math.max(...Object.values(scores));
|
|
231
|
+
if (maxScore === 0) return "other";
|
|
232
|
+
|
|
233
|
+
const winner = Object.entries(scores).find(([_, score]) => score === maxScore);
|
|
234
|
+
return winner ? (winner[0] as PRCategory) : "other";
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function getPRStats(prCommits: ParsedCommitData[]): PRStats {
|
|
238
|
+
return {
|
|
239
|
+
commitCount: prCommits.length,
|
|
240
|
+
};
|
|
241
|
+
}
|