Detect references in commit messages (#829)
Now that the GitHub plugin knows about commit messages (#828), we can parse those commit messages to find references to other GitHub entities. Fixed a minor typing mistake along the way. Test plan: Observe that a number of references have been detected among the commits in the example GitHub repository. We mistakenly find references to wchargin because we don't have a proper tokenizer. (#481) Progress on #815.
This commit is contained in:
parent
a1af9531ec
commit
ab85c9785b
|
@ -1,6 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
## [Unreleased]
|
||||
- Detect references in commit messages (#829)
|
||||
- Add commit authorship to the graph (#826)
|
||||
- Add `MentionsAuthor` edges to the graph (#808)
|
||||
<!-- Please add new entries to the _top_ of this section. -->
|
||||
|
|
|
@ -1465,6 +1465,88 @@ Array [
|
|||
"dstIndex": 2,
|
||||
"srcIndex": 34,
|
||||
},
|
||||
Object {
|
||||
"address": Array [
|
||||
"sourcecred",
|
||||
"github",
|
||||
"REFERENCES",
|
||||
"4",
|
||||
"sourcecred",
|
||||
"git",
|
||||
"COMMIT",
|
||||
"0a223346b4e6dec0127b1e6aa892c4ee0424b66a",
|
||||
"6",
|
||||
"sourcecred",
|
||||
"github",
|
||||
"PULL",
|
||||
"sourcecred",
|
||||
"example-github",
|
||||
"3",
|
||||
],
|
||||
"dstIndex": 33,
|
||||
"srcIndex": 0,
|
||||
},
|
||||
Object {
|
||||
"address": Array [
|
||||
"sourcecred",
|
||||
"github",
|
||||
"REFERENCES",
|
||||
"4",
|
||||
"sourcecred",
|
||||
"git",
|
||||
"COMMIT",
|
||||
"6bd1b4c0b719c22c688a74863be07a699b7b9b34",
|
||||
"5",
|
||||
"sourcecred",
|
||||
"github",
|
||||
"USERLIKE",
|
||||
"USER",
|
||||
"wchargin",
|
||||
],
|
||||
"dstIndex": 41,
|
||||
"srcIndex": 1,
|
||||
},
|
||||
Object {
|
||||
"address": Array [
|
||||
"sourcecred",
|
||||
"github",
|
||||
"REFERENCES",
|
||||
"4",
|
||||
"sourcecred",
|
||||
"git",
|
||||
"COMMIT",
|
||||
"6d5b3aa31ebb68a06ceb46bbd6cf49b6ccd6f5e6",
|
||||
"6",
|
||||
"sourcecred",
|
||||
"github",
|
||||
"PULL",
|
||||
"sourcecred",
|
||||
"example-github",
|
||||
"5",
|
||||
],
|
||||
"dstIndex": 34,
|
||||
"srcIndex": 2,
|
||||
},
|
||||
Object {
|
||||
"address": Array [
|
||||
"sourcecred",
|
||||
"github",
|
||||
"REFERENCES",
|
||||
"4",
|
||||
"sourcecred",
|
||||
"git",
|
||||
"COMMIT",
|
||||
"c430bd74455105f77215ece51945094ceeee6c86",
|
||||
"5",
|
||||
"sourcecred",
|
||||
"github",
|
||||
"USERLIKE",
|
||||
"USER",
|
||||
"wchargin",
|
||||
],
|
||||
"dstIndex": 41,
|
||||
"srcIndex": 3,
|
||||
},
|
||||
Object {
|
||||
"address": Array [
|
||||
"sourcecred",
|
||||
|
|
|
@ -351,5 +351,21 @@ Array [
|
|||
"from": "https://github.com/sourcecred/example-github/pull/3#issuecomment-369162222",
|
||||
"to": "https://github.com/sourcecred/example-github/issues/2",
|
||||
},
|
||||
Object {
|
||||
"from": "https://github.com/sourcecred/example-github/commit/0a223346b4e6dec0127b1e6aa892c4ee0424b66a",
|
||||
"to": "https://github.com/sourcecred/example-github/pull/3",
|
||||
},
|
||||
Object {
|
||||
"from": "https://github.com/sourcecred/example-github/commit/6d5b3aa31ebb68a06ceb46bbd6cf49b6ccd6f5e6",
|
||||
"to": "https://github.com/sourcecred/example-github/pull/5",
|
||||
},
|
||||
Object {
|
||||
"from": "https://github.com/sourcecred/example-github/commit/6bd1b4c0b719c22c688a74863be07a699b7b9b34",
|
||||
"to": "https://github.com/wchargin",
|
||||
},
|
||||
Object {
|
||||
"from": "https://github.com/sourcecred/example-github/commit/c430bd74455105f77215ece51945094ceeee6c86",
|
||||
"to": "https://github.com/wchargin",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
|
|
@ -208,6 +208,7 @@ export class GraphView {
|
|||
GN.Prefix.pull,
|
||||
GN.Prefix.review,
|
||||
GN.Prefix.comment,
|
||||
GitNode.Prefix.commit,
|
||||
],
|
||||
[
|
||||
GN.Prefix.repo,
|
||||
|
|
|
@ -91,7 +91,8 @@ export type TextContentAddress =
|
|||
| IssueAddress
|
||||
| PullAddress
|
||||
| ReviewAddress
|
||||
| CommentAddress;
|
||||
| CommentAddress
|
||||
| GitNode.CommitAddress;
|
||||
|
||||
// Each of these types may be referred to by something
|
||||
// with text content.
|
||||
|
|
|
@ -219,6 +219,7 @@ export class RelationalView {
|
|||
yield* this.pulls();
|
||||
yield* this.reviews();
|
||||
yield* this.comments();
|
||||
yield* this.commits();
|
||||
}
|
||||
|
||||
*parentEntities(): Iterator<ParentEntity> {
|
||||
|
@ -465,7 +466,8 @@ export class RelationalView {
|
|||
}
|
||||
for (const e of this.textContentEntities()) {
|
||||
const srcAddress = e.address();
|
||||
for (const {ref, refType} of parseReferences(e.body())) {
|
||||
const body = e instanceof Commit ? e.message() : e.body();
|
||||
for (const {ref, refType} of parseReferences(body)) {
|
||||
const refAddress = refToAddress.get(ref);
|
||||
if (refAddress != null) {
|
||||
switch (refType) {
|
||||
|
@ -544,6 +546,9 @@ export class RelationalView {
|
|||
case "COMMENT":
|
||||
entity = this.comment(address);
|
||||
break;
|
||||
case "COMMIT":
|
||||
entity = this.commit(address);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
`Unexpected referrer address type: ${(address.type: empty)}`
|
||||
|
@ -661,7 +666,7 @@ export class Repo extends _Entity<RepoEntry> {
|
|||
yield assertExists(pull, address);
|
||||
}
|
||||
}
|
||||
referencedBy(): Iterator<ReferentEntity> {
|
||||
referencedBy(): Iterator<TextContentEntity> {
|
||||
return this._view._referencedBy(this);
|
||||
}
|
||||
}
|
||||
|
@ -874,6 +879,9 @@ export class Commit extends _Entity<CommitEntry> {
|
|||
message(): string {
|
||||
return this._entry.message;
|
||||
}
|
||||
references(): Iterator<ReferentEntity> {
|
||||
return this._view._references(this);
|
||||
}
|
||||
}
|
||||
|
||||
type UserlikeEntry = {|
|
||||
|
@ -948,7 +956,7 @@ export function match<T>(handlers: MatchHandlers<T>, x: Entity): T {
|
|||
|
||||
export type Entity = Repo | Issue | Pull | Review | Comment | Commit | Userlike;
|
||||
export type AuthoredEntity = Issue | Pull | Review | Comment | Commit;
|
||||
export type TextContentEntity = Issue | Pull | Review | Comment;
|
||||
export type TextContentEntity = Issue | Pull | Review | Comment | Commit;
|
||||
export type ParentEntity = Repo | Issue | Pull | Review;
|
||||
export type ChildEntity = Issue | Pull | Review | Comment;
|
||||
export type ReferentEntity = Repo | Issue | Pull | Review | Comment | Userlike;
|
||||
|
|
Loading…
Reference in New Issue