staklink 0.3.12 → 0.3.14

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.
@@ -33608,6 +33608,33 @@ var Repo = class {
33608
33608
  `git checkout -f $(git remote show origin | sed -n '/HEAD branch/s/.*: //p')`
33609
33609
  );
33610
33610
  }
33611
+ async branchExists(branch) {
33612
+ try {
33613
+ const localCheck = await this.execCommand(`git show-ref --verify --quiet refs/heads/${branch}`).catch(() => null);
33614
+ if (localCheck !== null) {
33615
+ return true;
33616
+ }
33617
+ const remoteCheck = await this.execCommand(`git ls-remote --heads origin ${branch}`).catch(() => "");
33618
+ return remoteCheck.trim().length > 0;
33619
+ } catch (e) {
33620
+ return false;
33621
+ }
33622
+ }
33623
+ async generateUniqueBranchName(baseBranchName) {
33624
+ let branchName = baseBranchName;
33625
+ while (await this.branchExists(branchName)) {
33626
+ const parts = branchName.split("-");
33627
+ const lastPart = parts[parts.length - 1];
33628
+ const num = parseInt(lastPart, 10);
33629
+ if (!isNaN(num) && lastPart === num.toString()) {
33630
+ parts[parts.length - 1] = (num + 1).toString();
33631
+ branchName = parts.join("-");
33632
+ } else {
33633
+ branchName = `${branchName}-2`;
33634
+ }
33635
+ }
33636
+ return branchName;
33637
+ }
33611
33638
  async checkoutNew(branch) {
33612
33639
  return this.execCommand(`git checkout -b ${branch}`);
33613
33640
  }
@@ -33901,7 +33928,7 @@ var SSEManager = class {
33901
33928
  var sseManager = new SSEManager();
33902
33929
 
33903
33930
  // src/proxy/version.ts
33904
- var VERSION = "0.3.12";
33931
+ var VERSION = "0.3.13";
33905
33932
 
33906
33933
  // node_modules/uuid/dist/esm/stringify.js
33907
33934
  var byteToHex = [];
@@ -80311,11 +80338,16 @@ async function startProxyServer() {
80311
80338
  const isOnMain = await repo.isOnMainBranch();
80312
80339
  const isOnBaseBranch = await repo.isOnBranch(r.base_branch);
80313
80340
  if (isOnMain || isOnBaseBranch) {
80314
- console.log(`=> CHECKOUT to new branch: ${r.branch_name}`);
80315
- await repo.checkoutNew(r.branch_name);
80341
+ const uniqueBranchName = await repo.generateUniqueBranchName(r.branch_name);
80342
+ if (uniqueBranchName !== r.branch_name) {
80343
+ console.log(`=> Branch ${r.branch_name} exists, using ${uniqueBranchName} instead`);
80344
+ }
80345
+ console.log(`=> CHECKOUT to new branch: ${uniqueBranchName}`);
80346
+ await repo.checkoutNew(uniqueBranchName);
80316
80347
  }
80317
80348
  await repo.addAll();
80318
- console.log(`=> COMMIT to ${r.url} on branch: ${r.branch_name}`);
80349
+ const currentBranch = (await repo.printCurrentBranch()).trim();
80350
+ console.log(`=> COMMIT to ${r.url} on branch: ${currentBranch}`);
80319
80351
  await repo.commitWithCredentials(r.commit_name, code.git_credentials);
80320
80352
  }
80321
80353
  console.log(`=> PUSH to ${r.url}`);
@@ -80390,7 +80422,8 @@ ${diff.trim()}`);
80390
80422
  }
80391
80423
  } catch (prError) {
80392
80424
  console.error(`=> Failed to create PR for ${r.url}:`, prError);
80393
- prs[repoName] = `Error: ${prError instanceof Error ? prError.message : String(prError)}`;
80425
+ fail(res, prError);
80426
+ return;
80394
80427
  }
80395
80428
  }
80396
80429
  }
@@ -10905,7 +10905,7 @@ var glob = Object.assign(glob_, {
10905
10905
  glob.glob = glob;
10906
10906
 
10907
10907
  // src/proxy/version.ts
10908
- var VERSION = "0.3.12";
10908
+ var VERSION = "0.3.13";
10909
10909
 
10910
10910
  // src/cli.ts
10911
10911
  var STAKLINK_PROXY = "staklink-proxy";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "staklink",
3
3
  "displayName": "staklink",
4
4
  "description": "staklink process manager",
5
- "version": "0.3.12",
5
+ "version": "0.3.14",
6
6
  "type": "module",
7
7
  "publisher": "stakwork",
8
8
  "engines": {