Re-introduce a simplified git plugin (#685)

This commit re-introduces the git plugin, now that it has been radically
simplified as described in [1]. The new git plugin only has nodes for
commits and only has commit has-parent edges. As compared to the version
that was removed in #628, this plugin is far leaner. It doesn't bloat
the graph (for `sourcecred/sourcecred`, the git plugin data is just
164k), and as such doesn't incur much performance penalty.

Re-incorporating the git plugin also brings some tangible benefits. We
already had git nodes in the graph, as the GitHub plugin attaches them
to pull requests. Without any git plugin, these nodes are displayed as
"uknown nodes" with ugly descriptions. Also, including a git plugin,
even one that is very minimal, communicates to users that git is a
source of information to SourceCred, and that they can expect more from
it in the future.

Note that this commit breaks backcompat for existing repositories that
were locally loaded after #628. As such, it is best to
`rm -rf $SOURCECRED_DIRECTORY` and start with fresh data. Also, due to a
known bug in the WeightConfig, you should reset your browser's local
storage.

Test plan: After removing the SourceCred directory and the stale
localStorage, the cred explorer nicely displays git commits, and
connects them via has_parent edges. The NodeType filter allows filtering
to commits as expected, and the WeightConfig shows node and edge weights
for the Git plugin's nodes and edges.

[1]: https://github.com/sourcecred/sourcecred/issues/627#issuecomment-413435447
This commit is contained in:
Dandelion Mané 2018-08-16 13:20:41 -07:00 committed by GitHub
parent 024ca3c262
commit 2d28bd5de4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,7 @@
# Changelog
## [Unreleased]
- Introduce a simplified Git plugin that only tracks commits (#685)
- Rename cred explorer table columns (#680)
- Display version string in the app's footer
- Support hosting SourceCred instances at arbitrary gateways, not just

View File

@ -2,7 +2,8 @@
import {StaticAdapterSet} from "./adapterSet";
import {StaticPluginAdapter as GithubAdapter} from "../../plugins/github/pluginAdapter";
import {StaticPluginAdapter as GitAdapter} from "../../plugins/git/minimalPluginAdapter";
export function defaultStaticAdapters(): StaticAdapterSet {
return new StaticAdapterSet([new GithubAdapter()]);
return new StaticAdapterSet([new GithubAdapter(), new GitAdapter()]);
}

View File

@ -10,7 +10,7 @@ export function pluginNames(): PluginName[] {
}
export function defaultPlugins(): PluginName[] {
return ["github"];
return ["github", "git"];
}
function defaultStorageDirectory() {

View File

@ -4,7 +4,7 @@ import fs from "fs-extra";
import path from "path";
import cloneAndLoadRepository from "./cloneAndLoadRepository";
import {createGraph} from "./createGraph";
import {createMinimalGraph} from "./createMinimalGraph";
import type {Repo} from "../../core/repo";
export type Options = {|
@ -15,7 +15,7 @@ export type Options = {|
export function loadGitData(options: Options): Promise<void> {
const repository = cloneAndLoadRepository(options.repo);
const graph = createGraph(repository);
const graph = createMinimalGraph(repository);
const blob = JSON.stringify(graph);
const outputFilename = path.join(options.outputDirectory, "graph.json");
return fs.writeFile(outputFilename, blob);