mirror of
https://github.com/martinvonz/jj.git
synced 2024-09-21 10:50:22 +03:00
backend: make random ChangeId fully random, remove UUID mask bits
This commit is contained in:
parent
2144870e5c
commit
cd551bea34
@ -155,10 +155,7 @@ impl UserSettings {
|
||||
pub struct JJRng(Mutex<ChaCha20Rng>);
|
||||
impl JJRng {
|
||||
pub fn new_change_id(&self) -> ChangeId {
|
||||
let mut random_bytes: [u8; 16] = self.gen();
|
||||
// TODO: make it fully random
|
||||
random_bytes[6] = (random_bytes[6] & 0x0f) | ((4 as u8) << 4); // Version: 4
|
||||
random_bytes[8] = (random_bytes[8] & 0x3f) | 0x80; // Variant::RFC4122
|
||||
let random_bytes: [u8; 16] = self.gen();
|
||||
ChangeId::new(random_bytes.into())
|
||||
}
|
||||
|
||||
|
@ -246,14 +246,14 @@ fn test_git_push_existing_long_branch() {
|
||||
std::fs::write(workspace_root.join("file"), "contents").unwrap();
|
||||
test_env.jj_cmd_success(
|
||||
&workspace_root,
|
||||
&["branch", "create", "push-19b790168e7347a7ba98deae21e807c0"],
|
||||
&["branch", "create", "push-19b790168e73f7a73a98deae21e807c0"],
|
||||
);
|
||||
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["git", "push", "--change=@"]);
|
||||
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Branch changes to push to origin:
|
||||
Add branch push-19b790168e7347a7ba98deae21e807c0 to fa16a14170fb
|
||||
Add branch push-19b790168e73f7a73a98deae21e807c0 to fa16a14170fb
|
||||
"###);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user