git_graph: Add feature graph (#47861)

Anthony Eid created

We need another work of polish before end users are able to use the git
graph.


Release Notes:

- N/A

Change summary

Cargo.lock                        |  1 +
crates/git_graph/Cargo.toml       |  1 +
crates/git_graph/src/git_graph.rs | 10 +++++++++-
3 files changed, 11 insertions(+), 1 deletion(-)

Detailed changes

Cargo.lock 🔗

@@ -7196,6 +7196,7 @@ dependencies = [
  "anyhow",
  "collections",
  "db",
+ "feature_flags",
  "fs",
  "git",
  "git_ui",

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

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();