repository-provider 26.1.3 → 26.2.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": "26.1.3",
3
+ "version": "26.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -36,9 +36,9 @@
36
36
  "ava": "^4.0.1",
37
37
  "c8": "^7.11.0",
38
38
  "documentation": "^13.2.5",
39
- "repository-provider-test-support": "^1.9.6",
40
- "semantic-release": "^18.0.1",
41
- "typescript": "^4.6.0-dev.20220115"
39
+ "repository-provider-test-support": "^1.9.8",
40
+ "semantic-release": "^19.0.2",
41
+ "typescript": "^4.6.0-dev.20220124"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=14.18.3"
@@ -482,6 +482,13 @@ export class BaseProvider {
482
482
  return Branch;
483
483
  }
484
484
 
485
+ /**
486
+ * @return {Class} branch class used by the Provider
487
+ */
488
+ get tagClass() {
489
+ return Tag;
490
+ }
491
+
485
492
  /**
486
493
  * @return {Class} entry class used by the Provider
487
494
  */
package/src/branch.mjs CHANGED
@@ -82,6 +82,7 @@ export class Branch extends Ref {
82
82
  * @param {boolean} options.dry do not create a branch and do not commit only create dummy PR
83
83
  * @param {boolean} options.skipWithoutCommits do not create a PR if no commits are given
84
84
  * @param {boolean} options.bodyFromCommitMessages generate body from commit messages
85
+ * @param {string} [options.body] body of the PR
85
86
  * @return {Promise<PullRequest>}
86
87
  */
87
88
  async commitIntoPullRequest(commits, options) {
@@ -77,6 +77,14 @@ export class RepositoryGroup extends RepositoryOwner(NamedObject) {
77
77
  return this.provider.branchClass;
78
78
  }
79
79
 
80
+ /**
81
+ * By default we use the providers implementation.
82
+ * @return {Class} as defined in the provider
83
+ */
84
+ get tagClass() {
85
+ return this.provider.branchClass;
86
+ }
87
+
80
88
  /**
81
89
  * By default we use the providers implementation.
82
90
  * @return {Class} as defined in the provider
@@ -42,7 +42,7 @@ export class Repository extends NamedObject {
42
42
  * URLs of the repository
43
43
  * @return {string[]}
44
44
  */
45
- urls: { },
45
+ urls: {},
46
46
 
47
47
  cloneURL: { type: "url" },
48
48
 
@@ -229,6 +229,14 @@ export class Repository extends NamedObject {
229
229
  return false;
230
230
  }
231
231
 
232
+ /**
233
+ * Lookup the default branch.
234
+ * @return {Promise<Branch>} branch named after defaultBranchName
235
+ */
236
+ get defaultBranch() {
237
+ return this.branch(this.defaultBranchName);
238
+ }
239
+
232
240
  /**
233
241
  * Lookup branch by name.
234
242
  * @param {string} name
@@ -239,14 +247,6 @@ export class Repository extends NamedObject {
239
247
  return this._branches.get(name);
240
248
  }
241
249
 
242
- /**
243
- * Lookup the default branch.
244
- * @return {Promise<Branch>} branch named after defaultBranchName
245
- */
246
- get defaultBranch() {
247
- return this.branch(this.defaultBranchName);
248
- }
249
-
250
250
  /**
251
251
  * @return {AsyncIterator<Branch>} of all branches
252
252
  */
@@ -274,7 +274,7 @@ export class Repository extends NamedObject {
274
274
  * Internal branch creation does not call repository.initialize()
275
275
  * @param {string} name of the new branch
276
276
  * @param {Object} options
277
- * @return {Promise<Branch>} newly created branch
277
+ * @return {Branch} newly created branch
278
278
  */
279
279
  addBranch(name, options) {
280
280
  let branch = this._branches.get(name);
@@ -298,8 +298,14 @@ export class Repository extends NamedObject {
298
298
  this._branches.delete(name);
299
299
  }
300
300
 
301
- _addTag(tag) {
302
- this._tags.set(tag.name, tag);
301
+ /**
302
+ * Get a Tag.
303
+ * @param {string} name
304
+ * @return {Promise<Tag>}
305
+ */
306
+ async tag(name) {
307
+ await this.initializeTags();
308
+ return this._tags.get(name);
303
309
  }
304
310
 
305
311
  /**
@@ -315,13 +321,23 @@ export class Repository extends NamedObject {
315
321
  }
316
322
 
317
323
  /**
318
- * Get a Tag.
319
- * @param {string} name
320
- * @return {Promise<Tag>}
324
+ * Add a new {@link Tag}.
325
+ * Internal tag creation does not call repository.initialize()
326
+ * @param {string} name of the new tag
327
+ * @param {Object} options
328
+ * @return {Tag} newly created tag
321
329
  */
322
- async tag(name) {
323
- await this.initializeTags();
324
- return this._tags.get(name);
330
+ addTag(name, options) {
331
+ let tag = this._tags.get(name);
332
+ if (tag === undefined) {
333
+ tag = new this.tagClass(this, name, options);
334
+ }
335
+
336
+ return tag;
337
+ }
338
+
339
+ _addTag(tag) {
340
+ this._tags.set(tag.name, tag);
325
341
  }
326
342
 
327
343
  /**
@@ -498,6 +514,14 @@ export class Repository extends NamedObject {
498
514
  return this.owner.branchClass;
499
515
  }
500
516
 
517
+ /**
518
+ * By default we use the owners implementation.
519
+ * @return {Class} as defined in the owner
520
+ */
521
+ get tagClass() {
522
+ return this.owner.tagClass;
523
+ }
524
+
501
525
  /**
502
526
  * By default we use the owners implementation.
503
527
  * @return {Class} as defined in the owner