Skip to content

Commit ad57e70

Browse files
committed
Restore gitbutler as default storage path for dev and nightly
Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
1 parent 72dd6a8 commit ad57e70

File tree

11 files changed

+26
-37
lines changed

11 files changed

+26
-37
lines changed

crates/but-cherry-apply/tests/fixtures/scenario/shared.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function init-repo-with-files-and-remote () {
4343
EOF
4444

4545
# Make sure the target is set.
46-
mkdir .git/gitbutler.dev
47-
cat <<EOF >>.git/gitbutler.dev/virtual_branches.toml
46+
mkdir .git/gitbutler
47+
cat <<EOF >>.git/gitbutler/virtual_branches.toml
4848
[default_target]
4949
branchName = "main"
5050
remoteName = "origin"
@@ -62,4 +62,3 @@ function commit() {
6262
local message=${1:?first argument is the commit message}
6363
git commit -am "$message" --allow-empty
6464
}
65-

crates/but-core/src/repo_ext.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ pub trait RepositoryExt: Sized {
2525
/// * If the resolved path is outside of [`gix::Repository::git_dir`], the storage path
2626
/// becomes `<configured-path>/<project-handle>` so multiple projects can share one base path
2727
/// without clobbering each other. This also applies to relative paths like `../../shared`.
28-
/// * Otherwise defaults to `<git-dir>/gitbutler` for release builds and
29-
/// `<git-dir>/gitbutler.<channel>` for non-release builds.
28+
/// * Otherwise defaults to `<git-dir>/gitbutler` on all channels.
29+
// The idea is to support one storage location per channel once we can make sure that the previously
30+
// used metadata doesn't get lost, like the target branch, for instance by copying it over from stable.
3031
fn gitbutler_storage_path(&self) -> anyhow::Result<PathBuf>;
3132
/// Set all fields in `config` that are not `None` to disk into local repository configuration, or none of them.
3233
fn set_git_settings(&self, config: &GitConfigSettings) -> anyhow::Result<()>;

crates/but-ctx/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ pub struct Context {
9494
/// against `gitdir`; paths that stay inside `gitdir` must live under a
9595
/// top-level directory whose name starts with `gitbutler`. Any resolved
9696
/// path outside `gitdir` gets a `<configured-path>/<project-handle>`
97-
/// suffix. If that key is not configured, a channel-specific default is
98-
/// used.
97+
/// suffix. If that key is not configured, the default is `gitdir/gitbutler`
98+
/// on all channels.
9999
pub project_data_dir: PathBuf,
100100
/// The directory to store application caches in.
101101
pub app_cache_dir: Option<PathBuf>,

crates/but-hunk-dependency/tests/fixtures/scenario/shared.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function setup-remote-and-vbtoml () {
3535
EOF
3636

3737
# Make sure the target is set.
38-
mkdir .git/gitbutler.dev
39-
cat <<EOF >>.git/gitbutler.dev/virtual_branches.toml
38+
mkdir .git/gitbutler
39+
cat <<EOF >>.git/gitbutler/virtual_branches.toml
4040
[default_target]
4141
branchName = "main"
4242
remoteName = "origin"

crates/but-project-handle/src/storage_path.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn gitbutler_storage_path(repo: &gix::Repository) -> anyhow::Result<PathBuf>
2424
Some(Err(err)) => {
2525
Err(err).with_context(|| format!("{storage_key} contains an invalid path"))
2626
}
27-
None => Ok(git_dir.join(default_gitbutler_storage_dir_name(&channel))),
27+
None => Ok(git_dir.join(default_gitbutler_storage_dir_name())),
2828
}
2929
}
3030

@@ -98,12 +98,8 @@ fn validate_in_git_storage_path(
9898
Ok(())
9999
}
100100

101-
fn default_gitbutler_storage_dir_name(channel: &AppChannel) -> &'static str {
102-
match channel {
103-
AppChannel::Release => "gitbutler",
104-
AppChannel::Nightly => "gitbutler.nightly",
105-
AppChannel::Dev => "gitbutler.dev",
106-
}
101+
fn default_gitbutler_storage_dir_name() -> &'static str {
102+
"gitbutler"
107103
}
108104

109105
fn storage_path_config_key_for_channel(channel: &AppChannel) -> &'static str {

crates/but-project-handle/tests/project-handle/storage_path.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::path::{Path, PathBuf};
22

3-
use but_path::AppChannel;
43
use but_project_handle::{ProjectHandle, gitbutler_storage_path, storage_path_config_key};
54
use but_testsupport::{CommandExt as _, git, gix_testtools, open_repo};
65
use gix_testtools::tempfile::TempDir;
@@ -23,11 +22,7 @@ fn set_git_config(
2322
}
2423

2524
fn default_storage_dir_name() -> &'static str {
26-
match AppChannel::new() {
27-
AppChannel::Release => "gitbutler",
28-
AppChannel::Nightly => "gitbutler.nightly",
29-
AppChannel::Dev => "gitbutler.dev",
30-
}
25+
"gitbutler"
3126
}
3227

3328
#[test]

crates/but-worktrees/tests/fixtures/scenario/shared.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function init-repo-with-files-and-remote () {
4141
EOF
4242

4343
# Make sure the target is set.
44-
mkdir .git/gitbutler.dev
45-
cat <<EOF >>.git/gitbutler.dev/virtual_branches.toml
44+
mkdir .git/gitbutler
45+
cat <<EOF >>.git/gitbutler/virtual_branches.toml
4646
[default_target]
4747
branchName = "main"
4848
remoteName = "origin"
@@ -60,4 +60,3 @@ function commit() {
6060
local message=${1:?first argument is the commit message}
6161
git commit -am "$message" --allow-empty
6262
}
63-

crates/gitbutler-branch-actions/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ but-settings.workspace = true
2424
but-gerrit.workspace = true
2525
but-workspace = { workspace = true, features = ["legacy"] }
2626
but-rebase.workspace = true
27-
but-project-handle.workspace = true
2827
but-core = { workspace = true, features = ["legacy"] }
28+
but-project-handle.workspace = true
2929
but-graph.workspace = true
3030
but-oxidize.workspace = true
3131
but-forge.workspace = true

crates/gitbutler-project/src/project.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ impl Project {
348348

349349
/// Returns the path to the directory containing the `GitButler` state for this project.
350350
///
351-
/// By default this is `.git/gitbutler` for release builds and `.git/gitbutler.<channel>`
352-
/// for non-release builds. It can be overridden by setting `gitbutler.storagePath`
353-
/// on release, or `gitbutler.<channel>.storagePath` on non-release builds. Relative
354-
/// configured values are resolved against `.git`; if they stay inside `.git`, they must
355-
/// live under a top-level directory whose name starts with `gitbutler`. Any resolved path
356-
/// outside `.git` gets a project-handle suffix to keep different projects isolated.
351+
/// By default this is `.git/gitbutler` on all channels. It can be overridden by setting
352+
/// `gitbutler.storagePath` on release, or `gitbutler.<channel>.storagePath` on non-release
353+
/// builds. Relative configured values are resolved against `.git`; if they stay inside `.git`,
354+
/// they must live under a top-level directory whose name starts with `gitbutler`. Any
355+
/// resolved path outside `.git` gets a project-handle suffix to keep different projects
356+
/// isolated.
357357
pub(crate) fn gb_dir(&self) -> anyhow::Result<PathBuf> {
358358
gix::open(self.git_dir())?.gitbutler_storage_path()
359359
}

crates/gitbutler-testsupport/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,9 @@ pub mod read_only {
311311
}
312312

313313
fn set_storage_path_for_testing(git_dir: &Path) -> anyhow::Result<()> {
314-
git2::Repository::open(git_dir)?.config()?.set_str(
315-
but_project_handle::storage_path_config_key(),
316-
"gitbutler.dev",
317-
)?;
314+
git2::Repository::open(git_dir)?
315+
.config()?
316+
.set_str(but_project_handle::storage_path_config_key(), "gitbutler")?;
318317
Ok(())
319318
}
320319

0 commit comments

Comments
 (0)