Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_graph: Add feature graph (#47861)

Anthony Eid7c6f7118e4d3
diff --git a/Cargo.lock b/Cargo.lock
index fdc2a0c2241..0ad2709c786 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -7196,6 +7196,7 @@ dependencies = [
"anyhow",
"collections",
"db",
+ "feature_flags",
"fs",
"git",
"git_ui",
diff --git a/crates/git_graph/Cargo.toml b/crates/git_graph/Cargo.toml
index f3fb46ffe47..b3bcbc4c726 100644
--- a/crates/git_graph/Cargo.toml
+++ b/crates/git_graph/Cargo.toml
@@ -22,6 +22,7 @@ test-support = [
anyhow.workspace = true
collections.workspace = true
db.workspace = true
+feature_flags.workspace = true
git.workspace = true
git_ui.workspace = true
gpui.workspace = true
diff --git a/crates/git_graph/src/git_graph.rs b/crates/git_graph/src/git_graph.rs
index ec5065e5c2a..8ca21071814 100644
--- a/crates/git_graph/src/git_graph.rs
+++ b/crates/git_graph/src/git_graph.rs
@@ -1,4 +1,5 @@
use collections::{BTreeMap, HashMap};
+use feature_flags::{FeatureFlag, FeatureFlagAppExt as _};
use git::{
BuildCommitPermalinkParams, GitHostingProviderRegistry, GitRemote, Oid, ParsedGitRemote,
parse_git_remote_url,
@@ -29,6 +30,12 @@ use workspace::{
item::{Item, ItemEvent, SerializableItem},
};
+pub struct GitGraphFeatureFlag;
+
+impl FeatureFlag for GitGraphFeatureFlag {
+ const NAME: &'static str = "git-graph";
+}
+
const COMMIT_CIRCLE_RADIUS: Pixels = px(4.5);
const COMMIT_CIRCLE_STROKE_WIDTH: Pixels = px(1.5);
const LANE_WIDTH: Pixels = px(16.0);
@@ -496,7 +503,8 @@ pub fn init(cx: &mut App) {
cx.observe_new(|workspace: &mut workspace::Workspace, _, _| {
workspace.register_action_renderer(|div, workspace, _, cx| {
div.when(
- workspace.project().read(cx).active_repository(cx).is_some(),
+ workspace.project().read(cx).active_repository(cx).is_some()
+ && cx.has_flag::<GitGraphFeatureFlag>(),
|div| {
let workspace = workspace.weak_handle();