Skip to content

Commit

Permalink
Switch away from UUIDs because people don't like them
Browse files Browse the repository at this point in the history
  • Loading branch information
Caleb-T-Owens committed Feb 24, 2025
1 parent 0c48aec commit 64bb8b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
16 changes: 5 additions & 11 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/gitbutler-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ gitbutler-oxidize.workspace = true
gitbutler-repo.workspace = true
gitbutler-commit.workspace = true
uuid.workspace = true
rand = "0.9"
14 changes: 10 additions & 4 deletions crates/gitbutler-sync/src/stack_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use gitbutler_stack::{
};
use gitbutler_user::User;
use gix::bstr::ByteSlice;
use rand::Rng;

use crate::cloud::{push_to_gitbutler_server, remote, RemoteKind};

Expand Down Expand Up @@ -73,6 +74,14 @@ struct BranchHead {
id: gix::ObjectId,
}

/// The worlds most secure random string generator because uuids are "not cool"
fn generate_review_id() -> String {
let mut rng = rand::rng();
(0..11)
.map(|_| rng.sample(rand::distr::Alphanumeric) as char)
.collect::<String>()
}

/// Fetch the stack heads in order and attach a review_id if not already present.
fn branch_heads(
vb_state: &VirtualBranchesHandle,
Expand All @@ -98,10 +107,7 @@ fn branch_heads(
}

let head_oid = head.head_oid(stack_context, &stack_clone)?.to_gix();
let review_id = head
.review_id
.clone()
.unwrap_or_else(|| uuid::Uuid::new_v4().to_string());
let review_id = head.review_id.clone().unwrap_or_else(generate_review_id);
head.review_id = Some(review_id.clone());

heads.push(BranchHead {
Expand Down

0 comments on commit 64bb8b8

Please sign in to comment.