github-repository-provider 7.25.58 → 7.25.61
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/README.md +2 -1
- package/package.json +2 -2
- package/src/github-branch.mjs +31 -13
- package/src/github-repository.mjs +16 -2
package/README.md
CHANGED
|
@@ -308,13 +308,14 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
308
308
|
|
|
309
309
|
### refId
|
|
310
310
|
|
|
311
|
+
Get sha of a ref.
|
|
311
312
|
<https://developer.github.com/v3/git/refs/>
|
|
312
313
|
|
|
313
314
|
#### Parameters
|
|
314
315
|
|
|
315
316
|
* `ref` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
316
317
|
|
|
317
|
-
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)
|
|
318
|
+
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** sha of the ref
|
|
318
319
|
|
|
319
320
|
### deletePullRequest
|
|
320
321
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "github-repository-provider",
|
|
3
|
-
"version": "7.25.
|
|
3
|
+
"version": "7.25.61",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"content-entry": "^4.1.9",
|
|
34
34
|
"fetch-link-util": "^1.0.7",
|
|
35
|
-
"fetch-rate-limit-util": "^2.
|
|
35
|
+
"fetch-rate-limit-util": "^2.5.0",
|
|
36
36
|
"matching-iterator": "^2.0.3",
|
|
37
37
|
"node-fetch": "^3.2.3",
|
|
38
38
|
"one-time-execution-method": "^2.0.13",
|
package/src/github-branch.mjs
CHANGED
|
@@ -84,16 +84,13 @@ export class GithubBranch extends Branch {
|
|
|
84
84
|
})
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
r = await this.provider.fetchJSON(
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
);
|
|
87
|
+
r = await this.provider.fetchJSON(`repos/${this.slug}/git/${this.ref}`, {
|
|
88
|
+
method: "PATCH",
|
|
89
|
+
body: JSON.stringify({
|
|
90
|
+
...options,
|
|
91
|
+
sha: r.json.sha
|
|
92
|
+
})
|
|
93
|
+
});
|
|
97
94
|
|
|
98
95
|
return r.json;
|
|
99
96
|
}
|
|
@@ -103,11 +100,26 @@ export class GithubBranch extends Branch {
|
|
|
103
100
|
* @param {string} name
|
|
104
101
|
*/
|
|
105
102
|
async entry(name) {
|
|
103
|
+
if (this._entries) {
|
|
104
|
+
const entry = this._entries.get(name);
|
|
105
|
+
if (entry) {
|
|
106
|
+
return entry;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
this._entries = new Map();
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
const { json } = await this.provider.fetchJSON(
|
|
107
113
|
`repos/${this.slug}/contents/${name}?ref=${this.ref}`
|
|
108
114
|
);
|
|
109
115
|
|
|
110
|
-
|
|
116
|
+
const entry = new this.entryClass(
|
|
117
|
+
name,
|
|
118
|
+
Buffer.from(json.content, "base64")
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
this._entries.set(name, entry);
|
|
122
|
+
return entry;
|
|
111
123
|
}
|
|
112
124
|
|
|
113
125
|
/**
|
|
@@ -130,7 +142,7 @@ export class GithubBranch extends Branch {
|
|
|
130
142
|
);
|
|
131
143
|
|
|
132
144
|
this._commitForSha.set(sha, json);
|
|
133
|
-
|
|
145
|
+
|
|
134
146
|
return json;
|
|
135
147
|
}
|
|
136
148
|
|
|
@@ -163,6 +175,10 @@ export class GithubBranch extends Branch {
|
|
|
163
175
|
async *entries(patterns) {
|
|
164
176
|
const commit = await this.commitForSha(await this.refId());
|
|
165
177
|
|
|
178
|
+
if (!this._entries) {
|
|
179
|
+
this._entries = new Map();
|
|
180
|
+
}
|
|
181
|
+
|
|
166
182
|
for (const entry of matcher(await this.tree(commit.tree.sha), patterns, {
|
|
167
183
|
name: "path"
|
|
168
184
|
})) {
|
|
@@ -171,11 +187,13 @@ export class GithubBranch extends Branch {
|
|
|
171
187
|
yield new BaseCollectionEntry(entry.path);
|
|
172
188
|
break;
|
|
173
189
|
case "blob":
|
|
174
|
-
|
|
190
|
+
const e = new LazyBufferContentEntry(
|
|
175
191
|
entry.path,
|
|
176
192
|
parseInt(entry.mode, 8),
|
|
177
193
|
this
|
|
178
194
|
);
|
|
195
|
+
this._entries.set(e.path, e);
|
|
196
|
+
yield e;
|
|
179
197
|
break;
|
|
180
198
|
/* case "commit":
|
|
181
199
|
break;*/
|
|
@@ -100,13 +100,23 @@ export class GithubRepository extends Repository {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
|
+
* Get sha of a ref.
|
|
103
104
|
* {@link https://developer.github.com/v3/git/refs/}
|
|
104
105
|
* @param {string} ref
|
|
105
|
-
* @return {string} sha of the ref
|
|
106
|
+
* @return {Promise<string>} sha of the ref
|
|
106
107
|
*/
|
|
107
108
|
async refId(ref) {
|
|
108
109
|
ref = ref.replace(/^refs\//, "");
|
|
109
110
|
|
|
111
|
+
if (this._ref) {
|
|
112
|
+
const sha = this._ref.get(ref);
|
|
113
|
+
if (sha) {
|
|
114
|
+
return sha;
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
this._ref = new Map();
|
|
118
|
+
}
|
|
119
|
+
|
|
110
120
|
const { response, json } = await this.provider.fetchJSON(
|
|
111
121
|
`repos/${this.slug}/git/ref/${ref}`
|
|
112
122
|
);
|
|
@@ -116,7 +126,11 @@ export class GithubRepository extends Repository {
|
|
|
116
126
|
throw new Error(`No refId for '${this.fullName}' '${ref}'`);
|
|
117
127
|
}
|
|
118
128
|
|
|
119
|
-
|
|
129
|
+
const sha = json.object.sha;
|
|
130
|
+
|
|
131
|
+
this._ref.set(ref, sha);
|
|
132
|
+
|
|
133
|
+
return sha;
|
|
120
134
|
}
|
|
121
135
|
|
|
122
136
|
async createBranch(name, from, options) {
|