github-repository-provider 7.25.56 → 7.25.59
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 +3 -3
- package/package.json +1 -1
- package/src/github-branch.mjs +15 -1
- package/src/github-repository.mjs +16 -2
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ console.log(entry.name);
|
|
|
40
40
|
* [Parameters](#parameters-1)
|
|
41
41
|
* [entry](#entry)
|
|
42
42
|
* [Parameters](#parameters-2)
|
|
43
|
-
* [
|
|
43
|
+
* [commitForSha](#commitforsha)
|
|
44
44
|
* [Parameters](#parameters-3)
|
|
45
45
|
* [tree](#tree)
|
|
46
46
|
* [Parameters](#parameters-4)
|
|
@@ -117,7 +117,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
117
117
|
|
|
118
118
|
* `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
119
119
|
|
|
120
|
-
###
|
|
120
|
+
### commitForSha
|
|
121
121
|
|
|
122
122
|
<https://developer.github.com/v3/git/commits/#get-a-commit>
|
|
123
123
|
|
|
@@ -125,7 +125,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
|
|
|
125
125
|
|
|
126
126
|
* `sha` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
127
127
|
|
|
128
|
-
Returns **[
|
|
128
|
+
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** response
|
|
129
129
|
|
|
130
130
|
### tree
|
|
131
131
|
|
package/package.json
CHANGED
package/src/github-branch.mjs
CHANGED
|
@@ -140,10 +140,24 @@ export class GithubBranch extends Branch {
|
|
|
140
140
|
* @return {Object[]}
|
|
141
141
|
*/
|
|
142
142
|
async tree(sha) {
|
|
143
|
+
if (this._tree) {
|
|
144
|
+
const tree = this._tree.get(sha);
|
|
145
|
+
if (tree) {
|
|
146
|
+
return tree;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
this._tree = new Map();
|
|
150
|
+
}
|
|
151
|
+
|
|
143
152
|
const { json } = await this.provider.fetchJSON(
|
|
144
153
|
`repos/${this.slug}/git/trees/${sha}?recursive=1`
|
|
145
154
|
);
|
|
146
|
-
|
|
155
|
+
|
|
156
|
+
const tree = json.tree;
|
|
157
|
+
|
|
158
|
+
this._tree.set(sha, tree);
|
|
159
|
+
|
|
160
|
+
return tree;
|
|
147
161
|
}
|
|
148
162
|
|
|
149
163
|
async *entries(patterns) {
|
|
@@ -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) {
|