Skip to content

Commit

Permalink
branch -> bookmark in everything user-facing
Browse files Browse the repository at this point in the history
  • Loading branch information
gulbanana committed Nov 16, 2024
1 parent d88bbb3 commit 535e8b1
Show file tree
Hide file tree
Showing 23 changed files with 150 additions and 136 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## [0.23.0](releases/tag/v0.23.0)
This version is based on Jujutsu 0.23 and the recently-released Tauri 2.0.

### Changed
- Branches have been renamed to bookmarks. The setting `gg.ui.mark-unpushed-branches` has changed to `mark-unpushed-bookmarks`, but the old one will still work as well.

## [0.20.0](releases/tag/v0.20.0)
This version is based on Jujutsu 0.20.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ GG doesn't require [JJ](https://martinvonz.github.io/jj/latest/install-and-setup
- Use the right pane to inspect and edit revisions - set descriptions, issue commands, view their parents and changes.
- Drag revisions around to rebase them; move them into or out of a revision's parents to add merges and move entire subtrees. Or just abandon them entirely.
- Drag files around to squash them into new revisions or throw away changes (restoring from parents).
- Drag branches around to set or delete them.
- Drag bookmarks around to set or delete them.
- Right click on any of the above for more actions.
- Push and fetch git changes using the bottom bar.
- Undo anything with ⟲ in the bottom right corner.
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/src/config/gg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ large-repo-heuristic = 100000
# Stores a list of recently opened directories for shell integration
recent-workspaces = []

# When set, branches that are local-only or remote-only will be visually indicated.
mark-unpushed-branches = true
# When set, bookmarks that are local-only or remote-only will be visually indicated.
mark-unpushed-bookmarks = true

# "light" or "dark". If not set, your OS settings will be used.
# theme-override =
12 changes: 8 additions & 4 deletions src-tauri/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait GGSettings {
fn query_large_repo_heuristic(&self) -> i64;
fn query_auto_snapshot(&self) -> Option<bool>;
fn ui_theme_override(&self) -> Option<String>;
fn ui_mark_unpushed_branches(&self) -> bool;
fn ui_mark_unpushed_bookmarks(&self) -> bool;
#[allow(dead_code)]
fn ui_recent_workspaces(&self) -> Vec<String>;
}
Expand All @@ -40,10 +40,14 @@ impl GGSettings for UserSettings {
self.config().get_string("gg.ui.theme-override").ok()
}

fn ui_mark_unpushed_branches(&self) -> bool {
fn ui_mark_unpushed_bookmarks(&self) -> bool {
self.config()
.get_bool("gg.ui.mark-unpushed-branches")
.unwrap_or(true)
.get_bool("gg.ui.mark-unpushed-bookmarks")
.unwrap_or(
self.config()
.get_bool("gg.ui.mark-unpushed-branches")
.unwrap_or(true),
)
}

fn ui_recent_workspaces(&self) -> Vec<String> {
Expand Down
26 changes: 13 additions & 13 deletions src-tauri/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn build_main(app_handle: &AppHandle) -> tauri::Result<Menu<Wry>> {
&MenuItem::with_id(
app_handle,
"menu_revision_branch",
"Create branch",
"Create bookmark",
true,
None::<&str>,
)?,
Expand Down Expand Up @@ -208,7 +208,7 @@ pub fn build_context(
&MenuItem::with_id(
app_handle,
"revision_branch",
"Create branch",
"Create bookmark",
true,
None::<&str>,
)?,
Expand Down Expand Up @@ -368,7 +368,7 @@ pub fn handle_context(window: Window, ctx: Operand) -> Result<()> {
"branch_track",
matches!(
r#ref,
StoreRef::RemoteBranch {
StoreRef::RemoteBookmark {
is_tracked: false,
..
}
Expand All @@ -380,13 +380,13 @@ pub fn handle_context(window: Window, ctx: Operand) -> Result<()> {
"branch_untrack",
matches!(
r#ref,
StoreRef::LocalBranch {
StoreRef::LocalBookmark {
ref tracking_remotes,
..
} if !tracking_remotes.is_empty()
) || matches!(
r#ref,
StoreRef::RemoteBranch {
StoreRef::RemoteBookmark {
is_synced: false, // we can *see* the remote ref, and
is_tracked: true, // it has a local, and
is_absent: false, // that local is somewhere else
Expand All @@ -397,34 +397,34 @@ pub fn handle_context(window: Window, ctx: Operand) -> Result<()> {

// push a local to its remotes, or finish a CLI delete
context_menu.enable("branch_push_all",
matches!(r#ref, StoreRef::LocalBranch { ref tracking_remotes, .. } if !tracking_remotes.is_empty()) ||
matches!(r#ref, StoreRef::RemoteBranch { is_tracked: true, is_absent: true, .. }))?;
matches!(r#ref, StoreRef::LocalBookmark { ref tracking_remotes, .. } if !tracking_remotes.is_empty()) ||
matches!(r#ref, StoreRef::RemoteBookmark { is_tracked: true, is_absent: true, .. }))?;

// push a local to a selected remote, tracking first if necessary
context_menu.enable("branch_push_single",
matches!(r#ref, StoreRef::LocalBranch { potential_remotes, .. } if potential_remotes > 0))?;
matches!(r#ref, StoreRef::LocalBookmark { potential_remotes, .. } if potential_remotes > 0))?;

// fetch a local's remotes, or just a remote (unless we're deleting it; that would be silly)
context_menu.enable("branch_fetch_all",
matches!(r#ref, StoreRef::LocalBranch { ref tracking_remotes, .. } if !tracking_remotes.is_empty()) ||
matches!(r#ref, StoreRef::RemoteBranch { is_tracked, is_absent, .. } if (!is_tracked || !is_absent)))?;
matches!(r#ref, StoreRef::LocalBookmark { ref tracking_remotes, .. } if !tracking_remotes.is_empty()) ||
matches!(r#ref, StoreRef::RemoteBookmark { is_tracked, is_absent, .. } if (!is_tracked || !is_absent)))?;

// fetch a local, tracking first if necessary
context_menu.enable("branch_fetch_single",
matches!(r#ref, StoreRef::LocalBranch { available_remotes, .. } if available_remotes > 0))?;
matches!(r#ref, StoreRef::LocalBookmark { available_remotes, .. } if available_remotes > 0))?;

// rename a local, which also untracks remotes
context_menu.enable(
"branch_rename",
matches!(r#ref, StoreRef::LocalBranch { .. }),
matches!(r#ref, StoreRef::LocalBookmark { .. }),
)?;

// remove a local, or make a remote absent
context_menu.enable(
"branch_delete",
!matches!(
r#ref,
StoreRef::RemoteBranch {
StoreRef::RemoteBookmark {
is_absent: true,
is_tracked: true,
..
Expand Down
12 changes: 6 additions & 6 deletions src-tauri/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub struct RepoStatus {
pub working_copy: CommitId,
}

/// Branch or tag name with metadata.
/// Bookmark or tag name with metadata.
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(tag = "type")]
#[cfg_attr(
Expand All @@ -117,7 +117,7 @@ pub struct RepoStatus {
ts(export, export_to = "../src/messages/")
)]
pub enum StoreRef {
LocalBranch {
LocalBookmark {
branch_name: String,
has_conflict: bool,
/// Synchronized with all tracking remotes
Expand All @@ -127,7 +127,7 @@ pub enum StoreRef {
available_remotes: usize,
potential_remotes: usize,
},
RemoteBranch {
RemoteBookmark {
branch_name: String,
remote_name: String,
has_conflict: bool,
Expand All @@ -146,9 +146,9 @@ pub enum StoreRef {
impl StoreRef {
pub fn as_branch(&self) -> Result<&str> {
match self {
StoreRef::LocalBranch { branch_name, .. } => Ok(&branch_name),
StoreRef::RemoteBranch { branch_name, .. } => Ok(&branch_name),
_ => Err(anyhow!("not a local branch")),
StoreRef::LocalBookmark { branch_name, .. } => Ok(&branch_name),
StoreRef::RemoteBookmark { branch_name, .. } => Ok(&branch_name),
_ => Err(anyhow!("not a local bookmark")),
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src-tauri/src/messages/mutations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ pub struct MoveRef {
pub to_id: RevId,
}

/// XXX pushes all branches of a remote, all remotes of a branch, or one remotes of a branch - split up?
#[derive(Deserialize, Debug)]
#[serde(tag = "type")]
#[cfg_attr(
Expand All @@ -222,13 +221,13 @@ pub struct MoveRef {
ts(export, export_to = "../src/messages/")
)]
pub enum GitPush {
AllBranches {
AllBookmarks {
remote_name: String,
},
AllRemotes {
branch_ref: StoreRef,
},
RemoteBranch {
RemoteBookmark {
remote_name: String,
branch_ref: StoreRef,
},
Expand All @@ -242,13 +241,13 @@ pub enum GitPush {
ts(export, export_to = "../src/messages/")
)]
pub enum GitFetch {
AllBranches {
AllBookmarks {
remote_name: String,
},
AllRemotes {
branch_ref: StoreRef,
},
RemoteBranch {
RemoteBookmark {
remote_name: String,
branch_ref: StoreRef,
},
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/src/worker/gui_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl WorkspaceSession<'_> {
latest_query,
status: self.format_status(),
theme_override: self.data.settings.ui_theme_override(),
mark_unpushed_branches: self.data.settings.ui_mark_unpushed_branches(),
mark_unpushed_branches: self.data.settings.ui_mark_unpushed_bookmarks(),
})
}

Expand Down Expand Up @@ -1027,7 +1027,7 @@ fn build_ref_index(repo: &ReadonlyRepo) -> RefIndex {
if local_target.is_present() {
index.insert(
local_target.added_ids(),
messages::StoreRef::LocalBranch {
messages::StoreRef::LocalBookmark {
branch_name: branch_name.to_owned(),
has_conflict: local_target.has_conflict(),
is_synced: remote_refs.iter().all(|&(_, remote_ref)| {
Expand All @@ -1046,7 +1046,7 @@ fn build_ref_index(repo: &ReadonlyRepo) -> RefIndex {
for &(remote_name, remote_ref) in &remote_refs {
index.insert(
remote_ref.target.added_ids(),
messages::StoreRef::RemoteBranch {
messages::StoreRef::RemoteBookmark {
branch_name: branch_name.to_owned(),
remote_name: remote_name.to_owned(),
has_conflict: remote_ref.target.has_conflict(),
Expand Down
Loading

0 comments on commit 535e8b1

Please sign in to comment.