@argos-ci/core 4.0.0 → 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 +22 -20
  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
  }
@@ -692,11 +699,6 @@ var schema = {
692
699
  default: null,
693
700
  nullable: true
694
701
  },
695
- owner: {
696
- format: String,
697
- default: null,
698
- nullable: true
699
- },
700
702
  repository: {
701
703
  format: String,
702
704
  default: null,
@@ -859,7 +861,6 @@ var base64Encode = (obj) => Buffer.from(JSON.stringify(obj), "utf8").toString("b
859
861
  function getAuthToken({
860
862
  token,
861
863
  ciProvider,
862
- owner,
863
864
  repository,
864
865
  jobId,
865
866
  runId,
@@ -870,17 +871,18 @@ function getAuthToken({
870
871
  }
871
872
  switch (ciProvider) {
872
873
  case "github-actions": {
873
- if (!owner || !repository || !jobId || !runId) {
874
+ if (!repository || !jobId || !runId) {
874
875
  throw new Error(
875
876
  `Automatic GitHub Actions variables detection failed. Please add the 'ARGOS_TOKEN'`
876
877
  );
877
878
  }
879
+ const [owner, repo] = repository.split("/");
878
880
  return `tokenless-github-${base64Encode({
879
881
  owner,
880
- repository,
882
+ repository: repo,
881
883
  jobId,
882
884
  runId,
883
- prNumber
885
+ prNumber: prNumber ?? void 0
884
886
  })}`;
885
887
  }
886
888
  default:
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.0",
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": "807e4a9f3c4bfddd4197ed7394b032a39bc1c58e"
67
+ "gitHead": "7a4fac1862698b69ad47fa0c58e1fa5c13d6686f"
68
68
  }