mobbdev 0.0.184 → 0.0.186

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.mjs +25 -6
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1440,6 +1440,7 @@ var EnvVariablesZod = z5.object({
1440
1440
  var { GITLAB_API_TOKEN, GITHUB_API_TOKEN, GIT_PROXY_HOST } = EnvVariablesZod.parse(process.env);
1441
1441
 
1442
1442
  // src/features/analysis/scm/scm.ts
1443
+ import { setTimeout as setTimeout3 } from "node:timers/promises";
1443
1444
  import { z as z16 } from "zod";
1444
1445
 
1445
1446
  // src/features/analysis/scm/bitbucket/bitbucket.ts
@@ -4343,7 +4344,13 @@ async function getGitlabBranchList({
4343
4344
  const res = await api2.Branches.all(projectPath, {
4344
4345
  perPage: MAX_BRANCHES_FETCH
4345
4346
  });
4346
- return res.map((branch) => branch.name);
4347
+ res.sort((a, b) => {
4348
+ if (!a.commit?.committed_date || !b.commit?.committed_date) {
4349
+ return 0;
4350
+ }
4351
+ return new Date(b.commit?.committed_date).getTime() - new Date(a.commit?.committed_date).getTime();
4352
+ });
4353
+ return res.map((branch) => branch.name).slice(0, MAX_BRANCHES_FETCH);
4347
4354
  } catch (e) {
4348
4355
  return [];
4349
4356
  }
@@ -5585,11 +5592,23 @@ var BitbucketSCMLib = class extends SCMLib {
5585
5592
  }
5586
5593
  async createSubmitRequest(params) {
5587
5594
  this._validateAccessTokenAndUrl();
5588
- const pullRequestRes = await this.bitbucketSdk.createPullRequest({
5589
- ...params,
5590
- repoUrl: this.url
5591
- });
5592
- return String(z16.number().parse(pullRequestRes.id));
5595
+ for (let i = 0; i < 5; i++) {
5596
+ try {
5597
+ const pullRequestRes = await this.bitbucketSdk.createPullRequest({
5598
+ ...params,
5599
+ repoUrl: this.url
5600
+ });
5601
+ return String(z16.number().parse(pullRequestRes.id));
5602
+ } catch (e) {
5603
+ console.warn(`error creating pull request. Try number ${i + 1}`, e);
5604
+ await setTimeout3(1e3);
5605
+ if (4 === i) {
5606
+ console.error("error creating pull request", e);
5607
+ throw e;
5608
+ }
5609
+ }
5610
+ }
5611
+ throw new Error("error creating pull request, should not reach here");
5593
5612
  }
5594
5613
  async validateParams() {
5595
5614
  return validateBitbucketParams({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "0.0.184",
3
+ "version": "0.0.186",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.js",