@argos-ci/core 3.1.1 → 3.2.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.
Files changed (2) hide show
  1. package/dist/index.js +48 -39
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -6,6 +6,24 @@ import convict from "convict";
6
6
 
7
7
  // src/ci-environment/git.ts
8
8
  import { execSync } from "node:child_process";
9
+
10
+ // src/debug.ts
11
+ import createDebug from "debug";
12
+ var KEY = "@argos-ci/core";
13
+ var debug = createDebug(KEY);
14
+ var isDebugEnabled = createDebug.enabled(KEY);
15
+ var debugTime = (arg) => {
16
+ if (isDebugEnabled) {
17
+ console.time(arg);
18
+ }
19
+ };
20
+ var debugTimeEnd = (arg) => {
21
+ if (isDebugEnabled) {
22
+ console.timeEnd(arg);
23
+ }
24
+ };
25
+
26
+ // src/ci-environment/git.ts
9
27
  function checkIsGitRepository() {
10
28
  try {
11
29
  return execSync("git rev-parse --is-inside-work-tree").toString().trim() === "true";
@@ -32,18 +50,14 @@ function branch() {
32
50
  }
33
51
  }
34
52
  function getMergeBaseCommitShaWithDepth(input) {
35
- try {
36
- execSync(
37
- `git fetch --update-head-ok --depth ${input.depth} origin ${input.head}:${input.head}`
38
- );
39
- execSync(
40
- `git fetch --update-head-ok --depth ${input.depth} origin ${input.base}:${input.base}`
41
- );
42
- const mergeBase = execSync(`git merge-base ${input.head} ${input.base}`).toString().trim();
43
- return mergeBase || null;
44
- } catch {
45
- return null;
46
- }
53
+ execSync(
54
+ `git fetch --update-head-ok --depth ${input.depth} origin ${input.head}:${input.head}`
55
+ );
56
+ execSync(
57
+ `git fetch --update-head-ok --depth ${input.depth} origin ${input.base}:${input.base}`
58
+ );
59
+ const mergeBase = execSync(`git merge-base ${input.head} ${input.base}`).toString().trim();
60
+ return mergeBase || null;
47
61
  }
48
62
  function getMergeBaseCommitSha(input) {
49
63
  let depth = 200;
@@ -57,17 +71,31 @@ function getMergeBaseCommitSha(input) {
57
71
  }
58
72
  depth += 200;
59
73
  }
74
+ if (isDebugEnabled) {
75
+ const headShas = listShas(input.head);
76
+ const baseShas = listShas(input.base);
77
+ debug(
78
+ `No merge base found for ${input.head} and ${input.base} with depth ${depth}`
79
+ );
80
+ debug(
81
+ `Found ${headShas.length} commits in ${input.head}: ${headShas.join(", ")}`
82
+ );
83
+ debug(
84
+ `Found ${baseShas.length} commits in ${input.base}: ${baseShas.join(", ")}`
85
+ );
86
+ }
60
87
  return null;
61
88
  }
89
+ function listShas(path, maxCount) {
90
+ const maxCountArg = maxCount ? `--max-count=${maxCount}` : "";
91
+ const raw = execSync(`git log --format="%H" ${maxCountArg} ${path}`.trim());
92
+ const shas = raw.toString().trim().split("\n");
93
+ return shas;
94
+ }
62
95
  function listParentCommits(input) {
63
- try {
64
- execSync(`git fetch --depth=200 origin ${input.sha}`);
65
- const raw = execSync(`git log --format="%H" --max-count=200 ${input.sha}`);
66
- const shas = raw.toString().trim().split("\n");
67
- return shas;
68
- } catch {
69
- return null;
70
- }
96
+ const limit = 200;
97
+ execSync(`git fetch --depth=${limit} origin ${input.sha}`);
98
+ return listShas(input.sha, limit);
71
99
  }
72
100
 
73
101
  // src/ci-environment/services/bitrise.ts
@@ -150,25 +178,6 @@ var heroku_default = service3;
150
178
  // src/ci-environment/services/github-actions.ts
151
179
  import { existsSync, readFileSync } from "node:fs";
152
180
  import axios from "axios";
153
-
154
- // src/debug.ts
155
- import createDebug from "debug";
156
- var KEY = "@argos-ci/core";
157
- var debug = createDebug(KEY);
158
- var debugTime = (arg) => {
159
- const enabled = createDebug.enabled(KEY);
160
- if (enabled) {
161
- console.time(arg);
162
- }
163
- };
164
- var debugTimeEnd = (arg) => {
165
- const enabled = createDebug.enabled(KEY);
166
- if (enabled) {
167
- console.timeEnd(arg);
168
- }
169
- };
170
-
171
- // src/ci-environment/services/github-actions.ts
172
181
  async function getPullRequestFromHeadSha({ env }, sha) {
173
182
  debug("Fetching pull request number from head sha", sha);
174
183
  if (!env.GITHUB_REPOSITORY) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Node.js SDK for visual testing with Argos.",
4
- "version": "3.1.1",
4
+ "version": "3.2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "exports": {
@@ -64,5 +64,5 @@
64
64
  "lint": "eslint .",
65
65
  "test": "vitest"
66
66
  },
67
- "gitHead": "6385df8f840714c9d77c52b2035bdbbc1b148791"
67
+ "gitHead": "d357bd6744fb2210d1b8b1fe63de3ae61a51540c"
68
68
  }