@argos-ci/core 4.0.1 → 4.0.2

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 +18 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -57,23 +57,30 @@ function getRepositoryURL() {
57
57
  return null;
58
58
  }
59
59
  }
60
- function getMergeBaseCommitShaWithDepth(input) {
61
- execSync(
62
- `git fetch --update-head-ok --depth ${input.depth} origin ${input.head}:${input.head}`
63
- );
60
+ function gitMergeBase(input) {
61
+ try {
62
+ return execSync(`git merge-base ${input.head} ${input.base}`).toString().trim();
63
+ } catch (error) {
64
+ if (checkIsExecError(error) && error.status === 1 && error.stderr.toString() === "") {
65
+ return null;
66
+ }
67
+ throw error;
68
+ }
69
+ }
70
+ function gitFetch(input) {
64
71
  execSync(
65
- `git fetch --update-head-ok --depth ${input.depth} origin ${input.base}:${input.base}`
72
+ `git fetch --update-head-ok --depth ${input.depth} origin ${input.ref}:${input.ref}`
66
73
  );
67
- const mergeBase = execSync(`git merge-base ${input.head} ${input.base}`).toString().trim();
68
- return mergeBase || null;
74
+ }
75
+ function checkIsExecError(error) {
76
+ return error instanceof Error && "status" in error && typeof error.status === "number" && "stderr" in error && Buffer.isBuffer(error.stderr);
69
77
  }
70
78
  function getMergeBaseCommitSha(input) {
71
79
  let depth = 200;
72
80
  while (depth < 1e3) {
73
- const mergeBase = getMergeBaseCommitShaWithDepth({
74
- depth,
75
- ...input
76
- });
81
+ gitFetch({ ref: input.head, depth });
82
+ gitFetch({ ref: input.base, depth });
83
+ const mergeBase = gitMergeBase(input);
77
84
  if (mergeBase) {
78
85
  return mergeBase;
79
86
  }
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": "4.0.1",
4
+ "version": "4.0.2",
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": "db55659eaaffc6a3a92655f621be0d6344901da2"
67
+ "gitHead": "7a4fac1862698b69ad47fa0c58e1fa5c13d6686f"
68
68
  }