github-repository-provider 7.30.14 → 7.30.15
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
package/src/github-branch.mjs
CHANGED
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
* Branch on GitHub.
|
|
11
11
|
*/
|
|
12
12
|
export class GithubBranch extends Branch {
|
|
13
|
+
#entries;
|
|
14
|
+
#tree;
|
|
15
|
+
#commitForSha;
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Writes content into the branch
|
|
15
19
|
* {@link https://developer.github.com/v3/git/blobs/#get-a-blob}
|
|
@@ -42,7 +46,7 @@ export class GithubBranch extends Branch {
|
|
|
42
46
|
* @param {ContentEntry[]} entries
|
|
43
47
|
* @param {Object} options
|
|
44
48
|
*/
|
|
45
|
-
async commit(message, entries, options
|
|
49
|
+
async commit(message, entries, options) {
|
|
46
50
|
const updates = await Promise.all(
|
|
47
51
|
entries.map(entry => this.writeEntry(entry))
|
|
48
52
|
);
|
|
@@ -73,6 +77,8 @@ export class GithubBranch extends Branch {
|
|
|
73
77
|
})
|
|
74
78
|
});
|
|
75
79
|
|
|
80
|
+
//console.log("TREE", json.sha, shaLatestCommit);
|
|
81
|
+
|
|
76
82
|
let r = await this.provider.fetchJSON(`${this.api}/git/commits`, {
|
|
77
83
|
method: "POST",
|
|
78
84
|
body: JSON.stringify({
|
|
@@ -82,21 +88,9 @@ export class GithubBranch extends Branch {
|
|
|
82
88
|
})
|
|
83
89
|
});
|
|
84
90
|
|
|
85
|
-
|
|
86
|
-
method: "PATCH",
|
|
87
|
-
body: JSON.stringify({
|
|
88
|
-
...options,
|
|
89
|
-
sha: r.json.sha
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return r.json;
|
|
91
|
+
return this.owner.setRefId(this.ref, r.json.sha, options);
|
|
94
92
|
}
|
|
95
93
|
|
|
96
|
-
#entries;
|
|
97
|
-
#tree;
|
|
98
|
-
#commitForSha;
|
|
99
|
-
|
|
100
94
|
/**
|
|
101
95
|
* {@link https://developer.github.com/v3/repos/contents/#get-repository-content}
|
|
102
96
|
* @param {string} name
|
|
@@ -19,7 +19,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
19
19
|
url: "api"
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
static get attributes() {
|
|
24
24
|
return {
|
|
25
25
|
...super.attributes,
|
|
@@ -79,6 +79,7 @@ export class GithubPullRequest extends PullRequest {
|
|
|
79
79
|
return p;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
|
|
82
83
|
const { response, json } = await destination.provider.fetchJSON(
|
|
83
84
|
`${destination.repository.api}/pulls`,
|
|
84
85
|
{
|
|
@@ -90,10 +91,11 @@ export class GithubPullRequest extends PullRequest {
|
|
|
90
91
|
})
|
|
91
92
|
}
|
|
92
93
|
);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(response.statusText);
|
|
97
|
+
}
|
|
98
|
+
|
|
97
99
|
return new this(source, destination, json.number, json);
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -176,6 +176,27 @@ export class GithubRepository extends Repository {
|
|
|
176
176
|
return sha;
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
// TODO belongs into Ref ?
|
|
180
|
+
async setRefId(ref, sha, options) {
|
|
181
|
+
//console.log("NEW HEAD", sha, ref);
|
|
182
|
+
|
|
183
|
+
const r = await this.provider.fetchJSON(`${this.api}/git/${ref}`, {
|
|
184
|
+
method: "PATCH",
|
|
185
|
+
body: JSON.stringify({
|
|
186
|
+
...options,
|
|
187
|
+
sha
|
|
188
|
+
})
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
if (r.response.ok && this.#ref) {
|
|
192
|
+
this.#ref.set(ref, sha);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//console.log(r.response.ok, r.response.status, r.json);
|
|
196
|
+
|
|
197
|
+
return r.json;
|
|
198
|
+
}
|
|
199
|
+
|
|
179
200
|
async createBranch(name, from, options) {
|
|
180
201
|
await this.initializeBranches();
|
|
181
202
|
|