@pierre/storage 0.5.0 → 0.7.0

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/index.cjs CHANGED
@@ -472,7 +472,7 @@ function concatChunks(a, b) {
472
472
 
473
473
  // package.json
474
474
  var package_default = {
475
- version: "0.5.0"};
475
+ version: "0.7.0"};
476
476
 
477
477
  // src/version.ts
478
478
  var PACKAGE_NAME = "code-storage-sdk";
@@ -1565,8 +1565,9 @@ function transformGrepFileMatch(raw) {
1565
1565
  };
1566
1566
  }
1567
1567
  var RepoImpl = class {
1568
- constructor(id, options, generateJWT) {
1568
+ constructor(id, defaultBranch, options, generateJWT) {
1569
1569
  this.id = id;
1570
+ this.defaultBranch = defaultBranch;
1570
1571
  this.options = options;
1571
1572
  this.generateJWT = generateJWT;
1572
1573
  this.api = getApiInstance(
@@ -1987,7 +1988,7 @@ var GitStorage = class _GitStorage {
1987
1988
  provider: "github",
1988
1989
  ...snakecaseKeys__default.default(options.baseRepo)
1989
1990
  } : null;
1990
- const defaultBranch = options?.defaultBranch ?? "main";
1991
+ const defaultBranch = options?.baseRepo?.defaultBranch ?? options?.defaultBranch ?? "main";
1991
1992
  const createRepoPath = baseRepoOptions || defaultBranch ? {
1992
1993
  path: "repos",
1993
1994
  body: {
@@ -1999,7 +2000,7 @@ var GitStorage = class _GitStorage {
1999
2000
  if (resp.status === 409) {
2000
2001
  throw new Error("Repository already exists");
2001
2002
  }
2002
- return new RepoImpl(repoId, this.options, this.generateJWT.bind(this));
2003
+ return new RepoImpl(repoId, defaultBranch, this.options, this.generateJWT.bind(this));
2003
2004
  }
2004
2005
  /**
2005
2006
  * Find a repository by ID
@@ -2015,7 +2016,9 @@ var GitStorage = class _GitStorage {
2015
2016
  if (resp.status === 404) {
2016
2017
  return null;
2017
2018
  }
2018
- return new RepoImpl(options.id, this.options, this.generateJWT.bind(this));
2019
+ const body = await resp.json();
2020
+ const defaultBranch = body.default_branch ?? "main";
2021
+ return new RepoImpl(options.id, defaultBranch, this.options, this.generateJWT.bind(this));
2019
2022
  }
2020
2023
  /**
2021
2024
  * Delete a repository by ID