Include Pull additions/deletions (#444)
This adds additions and deletions to the v3 Pull data model, and also uses them in the pull descriptions. It's basically a port of #340 to v3. Test plan: Snapshots
This commit is contained in:
parent
6356c5477f
commit
baec3c15dd
|
@ -71,6 +71,8 @@ Array [
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`plugins/github/relationalView Pull has additions 1`] = `1`;
|
||||
|
||||
exports[`plugins/github/relationalView Pull has body 1`] = `
|
||||
"@wchargin could you please do the following:
|
||||
- add a commit comment
|
||||
|
@ -79,6 +81,8 @@ exports[`plugins/github/relationalView Pull has body 1`] = `
|
|||
- then approve the pr"
|
||||
`;
|
||||
|
||||
exports[`plugins/github/relationalView Pull has deletions 1`] = `0`;
|
||||
|
||||
exports[`plugins/github/relationalView Pull has mergedAs 1`] = `
|
||||
Object {
|
||||
"hash": "6d5b3aa31ebb68a06ceb46bbd6cf49b6ccd6f5e6",
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
exports[`plugins/github/render descriptions are as expected 1`] = `
|
||||
Object {
|
||||
"comment": "comment by @wchargin on review by @wchargin of #5: This pull request will be more contentious. I can feel it...",
|
||||
"comment": "comment by @wchargin on review by @wchargin of #5 (+1/−0): This pull request will be more contentious. I can feel it...",
|
||||
"issue": "#2: A referencing issue.",
|
||||
"pull": "#5: This pull request will be more contentious. I can feel it...",
|
||||
"pull": "#5 (+1/−0): This pull request will be more contentious. I can feel it...",
|
||||
"repo": "sourcecred/example-github",
|
||||
"review": "review by @wchargin of #5: This pull request will be more contentious. I can feel it...",
|
||||
"review": "review by @wchargin of #5 (+1/−0): This pull request will be more contentious. I can feel it...",
|
||||
"userlike": "@wchargin",
|
||||
}
|
||||
`;
|
||||
|
|
|
@ -255,6 +255,8 @@ export class RelationalView {
|
|||
body: json.body,
|
||||
title: json.title,
|
||||
mergedAs,
|
||||
additions: json.additions,
|
||||
deletions: json.deletions,
|
||||
};
|
||||
this._pulls.set(N.toRaw(address), entry);
|
||||
return address;
|
||||
|
@ -565,6 +567,8 @@ type PullEntry = {|
|
|||
+reviews: ReviewAddress[],
|
||||
+mergedAs: ?GitNode.CommitAddress,
|
||||
+nominalAuthor: ?UserlikeAddress,
|
||||
+additions: number,
|
||||
+deletions: number,
|
||||
|};
|
||||
|
||||
export class Pull extends _Entity<PullEntry> {
|
||||
|
@ -585,6 +589,12 @@ export class Pull extends _Entity<PullEntry> {
|
|||
body(): string {
|
||||
return this._entry.body;
|
||||
}
|
||||
additions(): number {
|
||||
return this._entry.additions;
|
||||
}
|
||||
deletions(): number {
|
||||
return this._entry.deletions;
|
||||
}
|
||||
mergedAs(): ?GitNode.CommitAddress {
|
||||
return this._entry.mergedAs;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ describe("plugins/github/relationalView", () => {
|
|||
has("url", () => entity.url());
|
||||
has("parent", () => entity.parent());
|
||||
has("mergedAs", () => entity.mergedAs());
|
||||
has("additions", () => entity.additions());
|
||||
has("deletions", () => entity.deletions());
|
||||
hasEntities("reviews", () => entity.reviews());
|
||||
hasEntities("comments", () => entity.comments());
|
||||
hasEntities("authors", () => entity.authors());
|
||||
|
|
|
@ -14,7 +14,10 @@ export function description(e: R.Entity) {
|
|||
const handlers = {
|
||||
repo: (x) => `${x.owner()}/${x.name()}`,
|
||||
issue: (x) => `#${x.number()}: ${x.title()}`,
|
||||
pull: (x) => `#${x.number()}: ${x.title()}`,
|
||||
pull: (x) => {
|
||||
const diff = `+${x.additions()}/\u2212${x.deletions()}`;
|
||||
return `#${x.number()} (${diff}): ${x.title()}`;
|
||||
},
|
||||
review: (x) => `review ${withAuthors(x)}of ${description(x.parent())}`,
|
||||
comment: (x) => `comment ${withAuthors(x)}on ${description(x.parent())}`,
|
||||
userlike: (x) => `@${x.login()}`,
|
||||
|
|
Loading…
Reference in New Issue