@regressionproof/snapshotter 0.5.2 → 0.5.3

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/build/esm/git.js CHANGED
@@ -33,11 +33,11 @@ export function gitCommit(mirrorPath, log) {
33
33
  export function gitPush(mirrorPath, remote, log) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
35
  const authedUrl = remote.url.replace('://', `://${remote.token}@`);
36
- try {
37
- yield execOrThrow(`git -C "${mirrorPath}" remote get-url origin`, log);
36
+ const originExists = yield remoteExists(mirrorPath, 'origin');
37
+ if (originExists) {
38
38
  yield execOrThrow(`git -C "${mirrorPath}" remote set-url origin "${authedUrl}"`);
39
39
  }
40
- catch (_a) {
40
+ else {
41
41
  yield execOrThrow(`git -C "${mirrorPath}" remote add origin "${authedUrl}"`);
42
42
  }
43
43
  yield execOrThrow(`git -C "${mirrorPath}" fetch origin`, log);
@@ -47,6 +47,18 @@ export function gitPush(mirrorPath, remote, log) {
47
47
  yield execOrThrow(`git -C "${mirrorPath}" push -u origin HEAD`, log);
48
48
  });
49
49
  }
50
+ function remoteExists(mirrorPath, remoteName) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ const { stdout } = yield execAsync(`git -C "${mirrorPath}" remote`);
54
+ const remotes = stdout.trim().split('\n');
55
+ return remotes.includes(remoteName);
56
+ }
57
+ catch (_a) {
58
+ return false;
59
+ }
60
+ });
61
+ }
50
62
  function hasRemoteHead(mirrorPath) {
51
63
  return __awaiter(this, void 0, void 0, function* () {
52
64
  try {
package/build/git.js CHANGED
@@ -28,11 +28,11 @@ async function gitCommit(mirrorPath, log) {
28
28
  }
29
29
  async function gitPush(mirrorPath, remote, log) {
30
30
  const authedUrl = remote.url.replace('://', `://${remote.token}@`);
31
- try {
32
- await execOrThrow(`git -C "${mirrorPath}" remote get-url origin`, log);
31
+ const originExists = await remoteExists(mirrorPath, 'origin');
32
+ if (originExists) {
33
33
  await execOrThrow(`git -C "${mirrorPath}" remote set-url origin "${authedUrl}"`);
34
34
  }
35
- catch {
35
+ else {
36
36
  await execOrThrow(`git -C "${mirrorPath}" remote add origin "${authedUrl}"`);
37
37
  }
38
38
  await execOrThrow(`git -C "${mirrorPath}" fetch origin`, log);
@@ -41,6 +41,16 @@ async function gitPush(mirrorPath, remote, log) {
41
41
  }
42
42
  await execOrThrow(`git -C "${mirrorPath}" push -u origin HEAD`, log);
43
43
  }
44
+ async function remoteExists(mirrorPath, remoteName) {
45
+ try {
46
+ const { stdout } = await execAsync(`git -C "${mirrorPath}" remote`);
47
+ const remotes = stdout.trim().split('\n');
48
+ return remotes.includes(remoteName);
49
+ }
50
+ catch {
51
+ return false;
52
+ }
53
+ }
44
54
  async function hasRemoteHead(mirrorPath) {
45
55
  try {
46
56
  await execAsync(`git -C "${mirrorPath}" symbolic-ref -q refs/remotes/origin/HEAD`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regressionproof/snapshotter",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -94,5 +94,5 @@
94
94
  "@sprucelabs/spruce-core-schemas": "^42.1.3",
95
95
  "@sprucelabs/spruce-skill-utils": "^34.0.3"
96
96
  },
97
- "gitHead": "b227dba3baef857f884befca26a119b9cfc545b7"
97
+ "gitHead": "d54c041a4d6b4cd88d35025ef1ee6d9acb6ad664"
98
98
  }