@postman-cse/onboarding-repo-sync 2.6.6 → 2.6.7

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/dist/action.cjs CHANGED
@@ -114484,7 +114484,7 @@ var RepoMutationService = class {
114484
114484
  "-m",
114485
114485
  "chore: sync Postman artifacts and metadata"
114486
114486
  ]);
114487
- const commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114487
+ let commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114488
114488
  if (options.repoWriteMode !== "commit-and-push") {
114489
114489
  return {
114490
114490
  commitSha,
@@ -114496,6 +114496,7 @@ var RepoMutationService = class {
114496
114496
  let pushed = false;
114497
114497
  let lastError = "";
114498
114498
  let remoteChanged = false;
114499
+ let stopCandidates = false;
114499
114500
  const isNonRetryablePushError = (message) => /workflow|permission/i.test(message);
114500
114501
  try {
114501
114502
  const pushCandidates = usePersistedCredentials ? [null] : tokens;
@@ -114515,18 +114516,54 @@ var RepoMutationService = class {
114515
114516
  ]);
114516
114517
  remoteChanged = true;
114517
114518
  }
114518
- const push = await this.execute("git", [
114519
- ...resetConfigArgs,
114520
- "push",
114521
- "origin",
114522
- `HEAD:refs/heads/${resolvedCurrentRef}`
114523
- ]);
114524
- if (push.exitCode === 0) {
114525
- pushed = true;
114526
- break;
114519
+ for (let pushAttempt = 0; pushAttempt < 2; pushAttempt += 1) {
114520
+ const fetch2 = await this.execute("git", [
114521
+ ...resetConfigArgs,
114522
+ "fetch",
114523
+ "--no-tags",
114524
+ "origin",
114525
+ `refs/heads/${resolvedCurrentRef}`
114526
+ ]);
114527
+ const fetchError = fetch2.stderr || fetch2.stdout || "";
114528
+ const targetBranchDoesNotExist = /couldn't find remote ref|remote ref .* not found/i.test(
114529
+ fetchError
114530
+ );
114531
+ if (fetch2.exitCode !== 0 && !targetBranchDoesNotExist) {
114532
+ lastError = fetchError;
114533
+ stopCandidates = isNonRetryablePushError(lastError);
114534
+ break;
114535
+ }
114536
+ if (fetch2.exitCode === 0) {
114537
+ const rebase = await this.execute("git", ["rebase", "FETCH_HEAD"]);
114538
+ if (rebase.exitCode !== 0) {
114539
+ await this.execute("git", ["rebase", "--abort"]);
114540
+ const cause = rebase.stderr || rebase.stdout || "Failed to rebase generated changes";
114541
+ throw new Error(
114542
+ secretMasker(
114543
+ `REPO_PUSH_RECONCILE_FAILED: Could not rebase generated changes onto ${resolvedCurrentRef}: ${cause}`
114544
+ )
114545
+ );
114546
+ }
114547
+ commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114548
+ }
114549
+ const push = await this.execute("git", [
114550
+ ...resetConfigArgs,
114551
+ "push",
114552
+ "origin",
114553
+ `HEAD:refs/heads/${resolvedCurrentRef}`
114554
+ ]);
114555
+ if (push.exitCode === 0) {
114556
+ pushed = true;
114557
+ break;
114558
+ }
114559
+ lastError = push.stderr || push.stdout || "";
114560
+ stopCandidates = isNonRetryablePushError(lastError);
114561
+ const targetAdvanced = /non-fast-forward|fetch first|remote contains work/i.test(lastError);
114562
+ if (stopCandidates || !targetAdvanced) {
114563
+ break;
114564
+ }
114527
114565
  }
114528
- lastError = push.stderr || push.stdout || "";
114529
- if (isNonRetryablePushError(lastError)) {
114566
+ if (pushed || stopCandidates) {
114530
114567
  break;
114531
114568
  }
114532
114569
  }
package/dist/cli.cjs CHANGED
@@ -112589,7 +112589,7 @@ var RepoMutationService = class {
112589
112589
  "-m",
112590
112590
  "chore: sync Postman artifacts and metadata"
112591
112591
  ]);
112592
- const commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
112592
+ let commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
112593
112593
  if (options.repoWriteMode !== "commit-and-push") {
112594
112594
  return {
112595
112595
  commitSha,
@@ -112601,6 +112601,7 @@ var RepoMutationService = class {
112601
112601
  let pushed = false;
112602
112602
  let lastError = "";
112603
112603
  let remoteChanged = false;
112604
+ let stopCandidates = false;
112604
112605
  const isNonRetryablePushError = (message) => /workflow|permission/i.test(message);
112605
112606
  try {
112606
112607
  const pushCandidates = usePersistedCredentials ? [null] : tokens;
@@ -112620,18 +112621,54 @@ var RepoMutationService = class {
112620
112621
  ]);
112621
112622
  remoteChanged = true;
112622
112623
  }
112623
- const push = await this.execute("git", [
112624
- ...resetConfigArgs,
112625
- "push",
112626
- "origin",
112627
- `HEAD:refs/heads/${resolvedCurrentRef}`
112628
- ]);
112629
- if (push.exitCode === 0) {
112630
- pushed = true;
112631
- break;
112624
+ for (let pushAttempt = 0; pushAttempt < 2; pushAttempt += 1) {
112625
+ const fetch2 = await this.execute("git", [
112626
+ ...resetConfigArgs,
112627
+ "fetch",
112628
+ "--no-tags",
112629
+ "origin",
112630
+ `refs/heads/${resolvedCurrentRef}`
112631
+ ]);
112632
+ const fetchError = fetch2.stderr || fetch2.stdout || "";
112633
+ const targetBranchDoesNotExist = /couldn't find remote ref|remote ref .* not found/i.test(
112634
+ fetchError
112635
+ );
112636
+ if (fetch2.exitCode !== 0 && !targetBranchDoesNotExist) {
112637
+ lastError = fetchError;
112638
+ stopCandidates = isNonRetryablePushError(lastError);
112639
+ break;
112640
+ }
112641
+ if (fetch2.exitCode === 0) {
112642
+ const rebase = await this.execute("git", ["rebase", "FETCH_HEAD"]);
112643
+ if (rebase.exitCode !== 0) {
112644
+ await this.execute("git", ["rebase", "--abort"]);
112645
+ const cause = rebase.stderr || rebase.stdout || "Failed to rebase generated changes";
112646
+ throw new Error(
112647
+ secretMasker(
112648
+ `REPO_PUSH_RECONCILE_FAILED: Could not rebase generated changes onto ${resolvedCurrentRef}: ${cause}`
112649
+ )
112650
+ );
112651
+ }
112652
+ commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
112653
+ }
112654
+ const push = await this.execute("git", [
112655
+ ...resetConfigArgs,
112656
+ "push",
112657
+ "origin",
112658
+ `HEAD:refs/heads/${resolvedCurrentRef}`
112659
+ ]);
112660
+ if (push.exitCode === 0) {
112661
+ pushed = true;
112662
+ break;
112663
+ }
112664
+ lastError = push.stderr || push.stdout || "";
112665
+ stopCandidates = isNonRetryablePushError(lastError);
112666
+ const targetAdvanced = /non-fast-forward|fetch first|remote contains work/i.test(lastError);
112667
+ if (stopCandidates || !targetAdvanced) {
112668
+ break;
112669
+ }
112632
112670
  }
112633
- lastError = push.stderr || push.stdout || "";
112634
- if (isNonRetryablePushError(lastError)) {
112671
+ if (pushed || stopCandidates) {
112635
112672
  break;
112636
112673
  }
112637
112674
  }
package/dist/index.cjs CHANGED
@@ -114507,7 +114507,7 @@ var RepoMutationService = class {
114507
114507
  "-m",
114508
114508
  "chore: sync Postman artifacts and metadata"
114509
114509
  ]);
114510
- const commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114510
+ let commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114511
114511
  if (options.repoWriteMode !== "commit-and-push") {
114512
114512
  return {
114513
114513
  commitSha,
@@ -114519,6 +114519,7 @@ var RepoMutationService = class {
114519
114519
  let pushed = false;
114520
114520
  let lastError = "";
114521
114521
  let remoteChanged = false;
114522
+ let stopCandidates = false;
114522
114523
  const isNonRetryablePushError = (message) => /workflow|permission/i.test(message);
114523
114524
  try {
114524
114525
  const pushCandidates = usePersistedCredentials ? [null] : tokens;
@@ -114538,18 +114539,54 @@ var RepoMutationService = class {
114538
114539
  ]);
114539
114540
  remoteChanged = true;
114540
114541
  }
114541
- const push = await this.execute("git", [
114542
- ...resetConfigArgs,
114543
- "push",
114544
- "origin",
114545
- `HEAD:refs/heads/${resolvedCurrentRef}`
114546
- ]);
114547
- if (push.exitCode === 0) {
114548
- pushed = true;
114549
- break;
114542
+ for (let pushAttempt = 0; pushAttempt < 2; pushAttempt += 1) {
114543
+ const fetch2 = await this.execute("git", [
114544
+ ...resetConfigArgs,
114545
+ "fetch",
114546
+ "--no-tags",
114547
+ "origin",
114548
+ `refs/heads/${resolvedCurrentRef}`
114549
+ ]);
114550
+ const fetchError = fetch2.stderr || fetch2.stdout || "";
114551
+ const targetBranchDoesNotExist = /couldn't find remote ref|remote ref .* not found/i.test(
114552
+ fetchError
114553
+ );
114554
+ if (fetch2.exitCode !== 0 && !targetBranchDoesNotExist) {
114555
+ lastError = fetchError;
114556
+ stopCandidates = isNonRetryablePushError(lastError);
114557
+ break;
114558
+ }
114559
+ if (fetch2.exitCode === 0) {
114560
+ const rebase = await this.execute("git", ["rebase", "FETCH_HEAD"]);
114561
+ if (rebase.exitCode !== 0) {
114562
+ await this.execute("git", ["rebase", "--abort"]);
114563
+ const cause = rebase.stderr || rebase.stdout || "Failed to rebase generated changes";
114564
+ throw new Error(
114565
+ secretMasker(
114566
+ `REPO_PUSH_RECONCILE_FAILED: Could not rebase generated changes onto ${resolvedCurrentRef}: ${cause}`
114567
+ )
114568
+ );
114569
+ }
114570
+ commitSha = (await this.execute("git", ["rev-parse", "HEAD"])).stdout.trim();
114571
+ }
114572
+ const push = await this.execute("git", [
114573
+ ...resetConfigArgs,
114574
+ "push",
114575
+ "origin",
114576
+ `HEAD:refs/heads/${resolvedCurrentRef}`
114577
+ ]);
114578
+ if (push.exitCode === 0) {
114579
+ pushed = true;
114580
+ break;
114581
+ }
114582
+ lastError = push.stderr || push.stdout || "";
114583
+ stopCandidates = isNonRetryablePushError(lastError);
114584
+ const targetAdvanced = /non-fast-forward|fetch first|remote contains work/i.test(lastError);
114585
+ if (stopCandidates || !targetAdvanced) {
114586
+ break;
114587
+ }
114550
114588
  }
114551
- lastError = push.stderr || push.stdout || "";
114552
- if (isNonRetryablePushError(lastError)) {
114589
+ if (pushed || stopCandidates) {
114553
114590
  break;
114554
114591
  }
114555
114592
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/onboarding-repo-sync",
3
- "version": "2.6.6",
3
+ "version": "2.6.7",
4
4
  "description": "Postman repo sync GitHub Action.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",