bitbucket-repository-provider 4.1.2 → 4.1.3
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": "bitbucket-repository-provider",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"content-entry": "^5.0.0",
|
|
34
|
-
"fetch-rate-limit-util": "^2.
|
|
34
|
+
"fetch-rate-limit-util": "^2.9.3",
|
|
35
35
|
"matching-iterator": "^2.0.4",
|
|
36
36
|
"node-fetch": "^3.2.3",
|
|
37
37
|
"one-time-execution-method": "^2.0.13",
|
|
38
|
-
"repository-provider": "^28.
|
|
38
|
+
"repository-provider": "^28.3.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"ava": "^4.2.0",
|
|
42
42
|
"c8": "^7.11.2",
|
|
43
43
|
"documentation": "^13.2.5",
|
|
44
|
-
"repository-provider-test-support": "^2.1.
|
|
44
|
+
"repository-provider-test-support": "^2.1.4",
|
|
45
45
|
"semantic-release": "^19.0.2"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
package/src/bitbucket-branch.mjs
CHANGED
|
@@ -25,12 +25,30 @@ export class BitbucketBranch extends Branch {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
// TODO isInitialized ?
|
|
29
|
+
|
|
30
|
+
async initialize()
|
|
31
|
+
{
|
|
32
|
+
if(this.hash === undefined) {
|
|
33
|
+
const url = `repositories/${this.slug}/refs/branches?q=name="${this.name}"`;
|
|
34
|
+
const { json } = await this.provider.fetchJSON(url);
|
|
35
|
+
// console.log(json.values[0].target);
|
|
36
|
+
|
|
37
|
+
this.hash = json.values[0].target.hash;
|
|
38
|
+
|
|
39
|
+
//delete json.values[0].target.repository;
|
|
40
|
+
//Object.assign(this,json.values[0].target);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
28
44
|
/**
|
|
29
45
|
* {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/src/%7Bnode%7D/%7Bpath%7D}
|
|
30
46
|
* @param {string} name
|
|
31
47
|
* @return {Promise<ContentEntry>}
|
|
32
48
|
*/
|
|
33
49
|
async entry(name) {
|
|
50
|
+
await this.initialize();
|
|
51
|
+
|
|
34
52
|
const res = await this.provider.fetch(
|
|
35
53
|
`repositories/${this.slug}/src/${this.hash}/${name}`
|
|
36
54
|
);
|
|
@@ -44,6 +62,8 @@ export class BitbucketBranch extends Branch {
|
|
|
44
62
|
* @param patterns
|
|
45
63
|
*/
|
|
46
64
|
async *entries(patterns) {
|
|
65
|
+
await this.initialize();
|
|
66
|
+
|
|
47
67
|
const { json } = await this.provider.fetchJSON(
|
|
48
68
|
`repositories/${this.slug}/src/${this.hash}/?max_depth=99`
|
|
49
69
|
);
|
|
@@ -70,9 +70,7 @@ export class BitbucketPullRequest extends PullRequest {
|
|
|
70
70
|
return p;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const { json } = await destination.provider.fetchJSON(url, {
|
|
73
|
+
const { json } = await destination.provider.fetchJSON(`repositories/${destination.slug}/pullrequests`, {
|
|
76
74
|
method: "POST",
|
|
77
75
|
data: {
|
|
78
76
|
source: {
|
|
@@ -22,12 +22,8 @@ export class BitbucketRepository extends Repository {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Object.defineProperties(this, {
|
|
29
|
-
user: { value: name.split(/\//)[0] }
|
|
30
|
-
});
|
|
25
|
+
get user() {
|
|
26
|
+
return this.name.split(/\//)[0];
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
/**
|
|
@@ -80,6 +76,9 @@ export class BitbucketRepository extends Repository {
|
|
|
80
76
|
} while (url);
|
|
81
77
|
}
|
|
82
78
|
|
|
79
|
+
/**
|
|
80
|
+
* {@link https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-group-refs}
|
|
81
|
+
*/
|
|
83
82
|
async initializeBranches() {
|
|
84
83
|
let url = `repositories/${this.slug}/refs/branches`;
|
|
85
84
|
|
|
@@ -111,7 +110,9 @@ export class BitbucketRepository extends Repository {
|
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
from = await from;
|
|
114
|
-
|
|
113
|
+
|
|
114
|
+
await from.initialize();
|
|
115
|
+
|
|
115
116
|
const { json } = await this.provider.fetchJSON(
|
|
116
117
|
`repositories/${this.slug}/refs/branches`,
|
|
117
118
|
{
|
|
@@ -133,10 +134,12 @@ export class BitbucketRepository extends Repository {
|
|
|
133
134
|
* {@link https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/refs/branches/%7Bname%7D#delete}
|
|
134
135
|
*/
|
|
135
136
|
async deleteBranch(name) {
|
|
136
|
-
const
|
|
137
|
-
|
|
137
|
+
const response = await this.provider.fetch(
|
|
138
|
+
`repositories/${this.slug}/refs/branches/${name}`,
|
|
139
|
+
{ method: "DELETE" }
|
|
140
|
+
);
|
|
138
141
|
|
|
139
|
-
if(!response.ok) {
|
|
142
|
+
if (!response.ok) {
|
|
140
143
|
throw new Error(response.statusText);
|
|
141
144
|
}
|
|
142
145
|
|