mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-05 00:15:03 +03:00
merged upstream
This commit is contained in:
commit
af6c6c17bb
@ -344,6 +344,8 @@ impl Repository {
|
||||
"created new session"
|
||||
);
|
||||
|
||||
self.flush_gitbutler_file(&session.id)?;
|
||||
|
||||
Ok(session)
|
||||
}
|
||||
|
||||
@ -593,6 +595,25 @@ impl Repository {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn flush_gitbutler_file(&self, session_id: &str) -> Result<()> {
|
||||
let gb_path = self.git_repository.path();
|
||||
let project_id = self.project.id.as_str();
|
||||
|
||||
let gb_file_content = serde_json::json!({
|
||||
"sessionId": session_id,
|
||||
"repositoryId": project_id,
|
||||
"gbPath": gb_path,
|
||||
"api": self.project.api,
|
||||
});
|
||||
|
||||
let gb_file_path = self.project.path.join(".git/gitbutler.json");
|
||||
std::fs::write(&gb_file_path, gb_file_content.to_string())?;
|
||||
|
||||
tracing::debug!("gitbutler file updated: {:?}", gb_file_path);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn build_wd_tree(
|
||||
|
@ -1,6 +1,7 @@
|
||||
use std::{collections::HashMap, path, thread, time};
|
||||
|
||||
use anyhow::Result;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::tempdir;
|
||||
|
||||
use crate::{
|
||||
@ -384,3 +385,28 @@ fn test_remote_sync_order() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_gitbutler_file() -> Result<()> {
|
||||
let Case {
|
||||
gb_repository,
|
||||
project_repository,
|
||||
..
|
||||
} = Suite::default().new_case();
|
||||
|
||||
let session = gb_repository.get_or_create_current_session()?;
|
||||
|
||||
let gitbutler_file_path = project_repository.path().join(".git/gitbutler.json");
|
||||
assert!(gitbutler_file_path.exists());
|
||||
|
||||
let file_content: serde_json::Value =
|
||||
serde_json::from_str(&std::fs::read_to_string(&gitbutler_file_path)?)?;
|
||||
|
||||
assert_eq!(file_content["sessionId"], session.id);
|
||||
assert_eq!(
|
||||
file_content["repositoryId"],
|
||||
project_repository.project().id
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user