repository-provider 28.3.15 → 28.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repository-provider",
3
- "version": "28.3.15",
3
+ "version": "28.4.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -105,13 +105,10 @@ export class MultiGroupProvider extends BaseProvider {
105
105
  * @return {RepositoryGroup}
106
106
  */
107
107
  addRepositoryGroup(name, options) {
108
- const normalizedName = this.normalizeGroupName(name, true);
108
+ return this.#repositoryGroups.get(this.normalizeGroupName(name, true)) || new this.repositoryGroupClass(this, name, options);
109
+ }
109
110
 
110
- let repositoryGroup = this.#repositoryGroups.get(normalizedName);
111
- if (repositoryGroup === undefined) {
112
- repositoryGroup = new this.repositoryGroupClass(this, name, options);
113
- this.#repositoryGroups.set(normalizedName, repositoryGroup);
114
- }
115
- return repositoryGroup;
111
+ _addRepositoryGroup(repositoryGroup) {
112
+ this.#repositoryGroups.set(this.normalizeGroupName(repositoryGroup.name, true), repositoryGroup);
116
113
  }
117
114
  }
@@ -1,5 +1,5 @@
1
1
  import { RepositoryOwner } from "./repository-owner.mjs";
2
- import { NamedObject } from "./named-object.mjs";
2
+ import { OwnedObject } from "./owned-object.mjs";
3
3
  import { BaseProvider } from "./base-provider.mjs";
4
4
 
5
5
  /**
@@ -16,7 +16,12 @@ import { BaseProvider } from "./base-provider.mjs";
16
16
  * @property {string} name
17
17
  */
18
18
 
19
- export class RepositoryGroup extends RepositoryOwner(NamedObject) {
19
+ export class RepositoryGroup extends RepositoryOwner(OwnedObject) {
20
+
21
+ static get registerInstanceMethodName() {
22
+ return "_addRepositoryGroup";
23
+ }
24
+
20
25
  static get attributes() {
21
26
  return {
22
27
  ...super.attributes,
@@ -43,15 +48,9 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
43
48
  return {};
44
49
  }
45
50
 
46
- constructor(provider, name, options) {
47
- super(name, options, {
48
- provider: { value: provider }
49
- });
50
- }
51
-
52
- get owner()
51
+ get provider()
53
52
  {
54
- return this.provider;
53
+ return this.owner;
55
54
  }
56
55
 
57
56
  get isAdmin() {
@@ -59,10 +58,10 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
59
58
  }
60
59
 
61
60
  get areRepositoryNamesCaseSensitive() {
62
- return this.provider.areRepositoryNamesCaseSensitive;
61
+ return this.owner.areRepositoryNamesCaseSensitive;
63
62
  }
64
63
 
65
64
  get areRepositoryGroupNamesCaseSensitive() {
66
- return this.provider.areRepositoryGroupNamesCaseSensitive;
65
+ return this.owner.areRepositoryGroupNamesCaseSensitive;
67
66
  }
68
67
  }
@@ -146,12 +146,7 @@ export function RepositoryOwner(base) {
146
146
  * @return {Promise<Repository>} newly created repository
147
147
  */
148
148
  addRepository(name, options) {
149
- const normalizedName = this.normalizeRepositoryName(name, true);
150
- let repository = this.#repositories.get(normalizedName);
151
- if (repository === undefined) {
152
- repository = new this.repositoryClass(this, name, options);
153
- }
154
- return repository;
149
+ return this.#repositories.get(this.normalizeRepositoryName(name, true)) || new this.repositoryClass(this, name, options);
155
150
  }
156
151
 
157
152
  _addRepository(repository)
@@ -242,12 +242,7 @@ export class Repository extends OwnedObject {
242
242
  */
243
243
  async branch(name) {
244
244
  if(name === this.defaultBranchName) {
245
- const branch = this._branches.get(name);
246
- if(branch) {
247
- return branch;
248
- }
249
-
250
- return this.addBranch(name);
245
+ return this._branches.get(name) || this.addBranch(name);
251
246
  }
252
247
 
253
248
  await this.initializeBranches();
@@ -284,12 +279,7 @@ export class Repository extends OwnedObject {
284
279
  * @return {Branch} newly created branch
285
280
  */
286
281
  addBranch(name, options) {
287
- let branch = this._branches.get(name);
288
- if (branch === undefined) {
289
- branch = new this.branchClass(this, name, options);
290
- }
291
-
292
- return branch;
282
+ return this._branches.get(name) || new this.branchClass(this, name, options);
293
283
  }
294
284
 
295
285
  _addBranch(branch) {
@@ -335,12 +325,7 @@ export class Repository extends OwnedObject {
335
325
  * @return {Tag} newly created tag
336
326
  */
337
327
  addTag(name, options) {
338
- let tag = this._tags.get(name);
339
- if (tag === undefined) {
340
- tag = new this.tagClass(this, name, options);
341
- }
342
-
343
- return tag;
328
+ return this._tags.get(name) || new this.tagClass(this, name, options);
344
329
  }
345
330
 
346
331
  _addTag(tag) {