Skip to content

Commit

Permalink
Prepare to rename EdgeDB -> Gel (#1390)
Browse files Browse the repository at this point in the history
Paves the way for a rename patch where we can rename EdgeDB to Gel in one swoop. Each use of EdgeDB is parameterized.

EdgeDB cloud strings have become BRANDING_CLOUD.

This patch doesn't perform the rename yet. We also don't perform any directory or configuration file migrations yet. We do, however, set the default config file to gel.toml.
  • Loading branch information
mmastrac authored Nov 8, 2024
1 parent 4e7988a commit 7e58bd2
Show file tree
Hide file tree
Showing 71 changed files with 862 additions and 547 deletions.
155 changes: 118 additions & 37 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ rustyline = { version = "14.0.0" }
clap = {workspace = true, features=["derive", "cargo", "deprecated", "wrap_help"]}
clap_complete = "4.4.3"
color-print = "0.3.5"
const_format = "0.2.33"
strsim = "0.11.0"
whoami = "1.1"
is-terminal = "0.4.4"
Expand Down Expand Up @@ -112,7 +113,7 @@ pem = "3.0.3"
rustls = { version = "0.23", features = ["ring"], default-features = false }
tokio-stream = "0.1.11"
futures-util = "0.3.15" # used for signals
clicolors-control = "1.0.1"
concolor = { version = "0.1.1", features = ["auto"] }
backtrace = "0.3.61"
arc-swap = "1.4.0"
ctrlc = "3.2.0"
Expand Down
25 changes: 12 additions & 13 deletions src/branch/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use edgedb_tokio::get_project_dir;
use edgedb_tokio::{get_project_path, get_stash_path};

use crate::branding::BRANDING_CLOUD;
use crate::commands::Options;
use crate::connect::Connection;
use crate::credentials;
Expand Down Expand Up @@ -31,12 +32,13 @@ impl Context {
// use instance name provided with --instance
let instance_name = options.conn_params.get()?.instance_name();
let mut instance_name: Option<InstanceName> = instance_name.map(|n| n.clone().into());
let project_dir = get_project_dir(None, true).await?;
let project_file = get_project_path(None, true).await?;
let project_dir = project_file.as_ref().map(|p| p.parent().unwrap());
let mut branch: Option<String> = None;

if instance_name.is_none() {
instance_name = if let Some(project_dir) = project_dir.as_ref() {
let stash_dir = project::stash_path(&fs::canonicalize(project_dir)?)?;
let stash_dir = get_stash_path(project_dir)?;
project::instance_name(&stash_dir).ok()
} else {
None
Expand All @@ -54,7 +56,7 @@ impl Context {
InstanceName::Cloud { org_slug, name } => anyhow::bail!(
// should never occur because of the above check
format!(
"cannot use Cloud instance {}/{}: instance is not linked to a project",
"cannot use {BRANDING_CLOUD} instance {}/{}: instance is not linked to a project",
org_slug, name
)
),
Expand All @@ -67,12 +69,12 @@ impl Context {
}
} else if let Some(project_dir) = project_dir.as_ref() {
// try read from the database file
let stash_dir = project::stash_path(&fs::canonicalize(project_dir)?)?;
let stash_dir = get_stash_path(project_dir)?;
branch = project::database_name(&stash_dir)?;
}

Ok(Context {
project_dir,
project_dir: project_dir.map(|p| p.to_owned()),
instance_name,
current_branch: branch,
})
Expand Down Expand Up @@ -122,8 +124,7 @@ impl Context {
} if self.project_dir.is_some() => {
// only place to store the branch is the database file in the project
let stash_path =
project::stash_path(&fs::canonicalize(self.project_dir.as_ref().unwrap())?)?
.join("database");
get_stash_path(self.project_dir.as_ref().unwrap())?.join("database");

// ensure that the temp file is created in the same directory as the 'database' file
let tmp = tmp_file_path(&stash_path);
Expand All @@ -137,19 +138,17 @@ impl Context {
name: inst,
} => {
anyhow::bail!(
format!("cannot switch branches on Cloud instance {}/{}: instance is not linked to a project", org, inst)
format!("cannot switch branches on {BRANDING_CLOUD} instance {}/{}: instance is not linked to a project", org, inst)
)
}
}
}

pub async fn get_project_config(&self) -> anyhow::Result<Option<Config>> {
let project_dir = get_project_dir(None, true).await?;
let project_dir = get_project_path(None, true).await?;
let Some(path) = &project_dir else {
return Ok(None);
};
Ok(Some(crate::portable::config::read(
&path.join("edgedb.toml"),
)?))
Ok(Some(crate::portable::config::read(&path)?))
}
}
Loading

0 comments on commit 7e58bd2

Please sign in to comment.