mirror of
https://github.com/status-im/sourcecred.git
synced 2025-02-20 00:08:10 +00:00
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
|
# Changelog
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
- Detect references in commit messages (#829)
|
||||||
- Add commit authorship to the graph (#826)
|
- Add commit authorship to the graph (#826)
|
||||||
- Add `MentionsAuthor` edges to the graph (#808)
|
- Add `MentionsAuthor` edges to the graph (#808)
|
||||||
<!-- Please add new entries to the _top_ of this section. -->
|
<!-- Please add new entries to the _top_ of this section. -->
|
||||||
|
@ -1465,6 +1465,88 @@ Array [
|
|||||||
"dstIndex": 2,
|
"dstIndex": 2,
|
||||||
"srcIndex": 34,
|
"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 {
|
Object {
|
||||||
"address": Array [
|
"address": Array [
|
||||||
"sourcecred",
|
"sourcecred",
|
||||||
|
@ -351,5 +351,21 @@ Array [
|
|||||||
"from": "https://github.com/sourcecred/example-github/pull/3#issuecomment-369162222",
|
"from": "https://github.com/sourcecred/example-github/pull/3#issuecomment-369162222",
|
||||||
"to": "https://github.com/sourcecred/example-github/issues/2",
|
"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.pull,
|
||||||
GN.Prefix.review,
|
GN.Prefix.review,
|
||||||
GN.Prefix.comment,
|
GN.Prefix.comment,
|
||||||
|
GitNode.Prefix.commit,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
GN.Prefix.repo,
|
GN.Prefix.repo,
|
||||||
|
@ -91,7 +91,8 @@ export type TextContentAddress =
|
|||||||
| IssueAddress
|
| IssueAddress
|
||||||
| PullAddress
|
| PullAddress
|
||||||
| ReviewAddress
|
| ReviewAddress
|
||||||
| CommentAddress;
|
| CommentAddress
|
||||||
|
| GitNode.CommitAddress;
|
||||||
|
|
||||||
// Each of these types may be referred to by something
|
// Each of these types may be referred to by something
|
||||||
// with text content.
|
// with text content.
|
||||||
|
@ -219,6 +219,7 @@ export class RelationalView {
|
|||||||
yield* this.pulls();
|
yield* this.pulls();
|
||||||
yield* this.reviews();
|
yield* this.reviews();
|
||||||
yield* this.comments();
|
yield* this.comments();
|
||||||
|
yield* this.commits();
|
||||||
}
|
}
|
||||||
|
|
||||||
*parentEntities(): Iterator<ParentEntity> {
|
*parentEntities(): Iterator<ParentEntity> {
|
||||||
@ -465,7 +466,8 @@ export class RelationalView {
|
|||||||
}
|
}
|
||||||
for (const e of this.textContentEntities()) {
|
for (const e of this.textContentEntities()) {
|
||||||
const srcAddress = e.address();
|
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);
|
const refAddress = refToAddress.get(ref);
|
||||||
if (refAddress != null) {
|
if (refAddress != null) {
|
||||||
switch (refType) {
|
switch (refType) {
|
||||||
@ -544,6 +546,9 @@ export class RelationalView {
|
|||||||
case "COMMENT":
|
case "COMMENT":
|
||||||
entity = this.comment(address);
|
entity = this.comment(address);
|
||||||
break;
|
break;
|
||||||
|
case "COMMIT":
|
||||||
|
entity = this.commit(address);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unexpected referrer address type: ${(address.type: empty)}`
|
`Unexpected referrer address type: ${(address.type: empty)}`
|
||||||
@ -661,7 +666,7 @@ export class Repo extends _Entity<RepoEntry> {
|
|||||||
yield assertExists(pull, address);
|
yield assertExists(pull, address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
referencedBy(): Iterator<ReferentEntity> {
|
referencedBy(): Iterator<TextContentEntity> {
|
||||||
return this._view._referencedBy(this);
|
return this._view._referencedBy(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -874,6 +879,9 @@ export class Commit extends _Entity<CommitEntry> {
|
|||||||
message(): string {
|
message(): string {
|
||||||
return this._entry.message;
|
return this._entry.message;
|
||||||
}
|
}
|
||||||
|
references(): Iterator<ReferentEntity> {
|
||||||
|
return this._view._references(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserlikeEntry = {|
|
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 Entity = Repo | Issue | Pull | Review | Comment | Commit | Userlike;
|
||||||
export type AuthoredEntity = Issue | Pull | Review | Comment | Commit;
|
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 ParentEntity = Repo | Issue | Pull | Review;
|
||||||
export type ChildEntity = Issue | Pull | Review | Comment;
|
export type ChildEntity = Issue | Pull | Review | Comment;
|
||||||
export type ReferentEntity = Repo | Issue | Pull | Review | Comment | Userlike;
|
export type ReferentEntity = Repo | Issue | Pull | Review | Comment | Userlike;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user