commit diff/patch getters
This commit is contained in:
parent
f6f71b64d2
commit
7e82b27acf
|
@ -111,7 +111,9 @@ export interface MergeRequest extends RepoElement {
|
|||
export interface Commit extends RepoElement {
|
||||
type: ENTITY_TYPE.COMMIT;
|
||||
patchURL: string;
|
||||
patchContent: () => Promise<string>;
|
||||
diffURL: string;
|
||||
diffContent: () => Promise<string>;
|
||||
}
|
||||
|
||||
/** the account that did an action */
|
||||
|
|
3
src/vendor/github/repomgr.ts
vendored
3
src/vendor/github/repomgr.ts
vendored
|
@ -219,9 +219,10 @@ export default class GitHubRepoManager implements RepoManager {
|
|||
content: c.messageBody,
|
||||
repo: this.repo,
|
||||
url: `${this.repo.url}/commit/${c.oid}`,
|
||||
// won't work on private repositories
|
||||
patchURL: `${this.repo.url}/commit/${c.oid}.patch`,
|
||||
patchContent: () => this.vendorMgr._http_get(`${this.repo.url}/commit/${c.oid}.patch`),
|
||||
diffURL: `${this.repo.url}/commit/${c.oid}.diff`,
|
||||
diffContent: () => this.vendorMgr._http_get(`${this.repo.url}/commit/${c.oid}.diff`),
|
||||
})),
|
||||
isDraft: pullRequest.isDraft,
|
||||
url: `${this.repo.url}/pull/${pullRequest.number}`,
|
||||
|
|
11
src/vendor/github/vendormgr.ts
vendored
11
src/vendor/github/vendormgr.ts
vendored
|
@ -56,4 +56,15 @@ export default class GitHubVendorManager implements VendorManager<GitHubConfig>
|
|||
.then((res) => JSON.parse(res.body))
|
||||
.then((res) => res.data) as Promise<T>;
|
||||
}
|
||||
|
||||
/** used to provide diff/patch contents */
|
||||
public async _http_get(url: string | URL): Promise<string> {
|
||||
return got
|
||||
.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.config.token}`,
|
||||
},
|
||||
})
|
||||
.then((res) => res.body);
|
||||
}
|
||||
}
|
||||
|
|
2
src/vendor/gitlab/repomgr.ts
vendored
2
src/vendor/gitlab/repomgr.ts
vendored
|
@ -224,7 +224,9 @@ export default class GitHubRepoManager implements RepoManager {
|
|||
repo: this.repo,
|
||||
url: `${this.repo.url}/-/commit/${c.id}`,
|
||||
diffURL: `${this.repo.url}/-/commit/${c.id}.diff`,
|
||||
diffContent: () => this.vendorMgr._http_get(`${this.repo.url}/-/commit/${c.id}.diff`),
|
||||
patchURL: `${this.repo.url}/-/commit/${c.id}.patch`,
|
||||
patchContent: () => this.vendorMgr._http_get(`${this.repo.url}/-/commit/${c.id}.patch`),
|
||||
})),
|
||||
url: `${this.repo.url}/-/merge_requests/${mergeRequest.iid}`,
|
||||
};
|
||||
|
|
11
src/vendor/gitlab/vendormgr.ts
vendored
11
src/vendor/gitlab/vendormgr.ts
vendored
|
@ -70,4 +70,15 @@ export default class GitLabVendorManager implements VendorManager<GitLabConfig>
|
|||
},
|
||||
}).then((res) => JSON.parse(res.body) as T);
|
||||
}
|
||||
|
||||
/** used to provide diff/patch contents */
|
||||
public async _http_get(url: string | URL): Promise<string> {
|
||||
return got
|
||||
.get(url, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${this.config.token}`,
|
||||
},
|
||||
})
|
||||
.then((res) => res.body);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue