-
Notifications
You must be signed in to change notification settings - Fork 105
feat: add metadata to entry object and store it in database && update filepath #1609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e00d9e2
9731b5c
4b68a5a
7ea684f
7771ba7
6f553e9
323280a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ use tokio::sync::Mutex; | |||
| use async_trait::async_trait; | ||||
| use git_internal::errors::GitError; | ||||
| use git_internal::hash::SHA1; | ||||
| use git_internal::internal::metadata::{EntryMeta, MetaAttached}; | ||||
| use git_internal::internal::object::commit::Commit; | ||||
| use git_internal::internal::object::tree::{Tree, TreeItem, TreeItemMode}; | ||||
| use git_internal::internal::pack::entry::Entry; | ||||
|
|
@@ -443,12 +444,21 @@ impl ApiHandler for ImportApiService { | |||
| Commit::from_tree_id(new_root_id, vec![parent_id], &payload.commit_message); | ||||
| let new_commit_id = new_commit.id.to_string(); | ||||
|
|
||||
| let mut entries: Vec<Entry> = Vec::new(); | ||||
| let mut entries: Vec<MetaAttached<Entry, EntryMeta>> = Vec::new(); | ||||
| for t in updated_trees.iter().cloned() { | ||||
| entries.push(Entry::from(t)); | ||||
| entries.push(MetaAttached { | ||||
| inner: Entry::from(t), | ||||
| meta: EntryMeta::new(), | ||||
| }); | ||||
| } | ||||
| entries.push(Entry::from(new_blob.clone())); | ||||
| entries.push(Entry::from(new_commit.clone())); | ||||
| entries.push(MetaAttached { | ||||
| inner: Entry::from(new_blob.clone()), | ||||
| meta: EntryMeta::new(), | ||||
| }); | ||||
| entries.push(MetaAttached { | ||||
| inner: Entry::from(new_commit.clone()), | ||||
| meta: EntryMeta::new(), | ||||
| }); | ||||
| git_storage | ||||
| .save_entry(self.repo.repo_id, entries) | ||||
| .await | ||||
|
|
@@ -788,6 +798,9 @@ impl ImportApiService { | |||
| tag_name: name, | ||||
| tagger: tagger_info, | ||||
| message: message.unwrap_or_default(), | ||||
| pack_id: String::new(), | ||||
| pack_offset: 0, | ||||
|
|
||||
|
||||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,3 +1,6 @@ | ||||
| use async_recursion::async_recursion; | ||||
| use async_trait::async_trait; | ||||
| use futures::StreamExt; | ||||
| use std::{ | ||||
| collections::{HashMap, HashSet}, | ||||
| path::PathBuf, | ||||
|
|
@@ -7,9 +10,6 @@ use std::{ | |||
| atomic::{AtomicUsize, Ordering}, | ||||
| }, | ||||
| }; | ||||
|
|
||||
| use async_trait::async_trait; | ||||
| use futures::StreamExt; | ||||
| use tokio::sync::{ | ||||
| Mutex, | ||||
| mpsc::{self}, | ||||
|
|
@@ -18,6 +18,7 @@ use tokio_stream::wrappers::ReceiverStream; | |||
|
|
||||
| use callisto::{mega_tree, raw_blob, sea_orm_active_enums::RefTypeEnum}; | ||||
| use common::errors::MegaError; | ||||
| use git_internal::internal::metadata::{EntryMeta, MetaAttached}; | ||||
| use git_internal::{ | ||||
| errors::GitError, | ||||
| internal::{ | ||||
|
|
@@ -65,14 +66,23 @@ impl RepoHandler for ImportRepo { | |||
|
|
||||
| async fn post_receive_pack(&self) -> Result<(), MegaError> { | ||||
| let _guard = self.shared.lock().await; | ||||
| self.traverses_tree_and_update_filepath().await?; | ||||
| self.attach_to_monorepo_parent().await | ||||
| } | ||||
|
|
||||
| async fn save_entry(&self, entry_list: Vec<Entry>) -> Result<(), MegaError> { | ||||
| async fn save_entry( | ||||
| &self, | ||||
| entry_list: Vec<MetaAttached<Entry, EntryMeta>>, | ||||
| ) -> Result<(), MegaError> { | ||||
| let storage = self.storage.git_db_storage(); | ||||
| storage.save_entry(self.repo.repo_id, entry_list).await | ||||
| } | ||||
|
|
||||
| async fn update_pack_id(&self, temp_pack_id: &str, pack_id: &str) -> Result<(), MegaError> { | ||||
| let storage = self.storage.git_db_storage(); | ||||
| storage.update_pack_id(temp_pack_id, pack_id).await | ||||
| } | ||||
|
|
||||
| async fn check_entry(&self, _: &Entry) -> Result<(), GitError> { | ||||
| Ok(()) | ||||
| } | ||||
|
|
@@ -96,7 +106,10 @@ impl RepoHandler for ImportRepo { | |||
| match model { | ||||
| Ok(m) => { | ||||
| let c: Commit = Commit::from_git_model(m); | ||||
| let entry = c.into(); | ||||
| let entry = MetaAttached { | ||||
| inner: c.into(), | ||||
| meta: EntryMeta::new(), | ||||
| }; | ||||
| entry_tx.send(entry).await.unwrap(); | ||||
| } | ||||
| Err(err) => eprintln!("Error: {err:?}"), | ||||
|
|
@@ -109,7 +122,10 @@ impl RepoHandler for ImportRepo { | |||
| match model { | ||||
| Ok(m) => { | ||||
| let t: Tree = Tree::from_git_model(m); | ||||
| let entry = t.into(); | ||||
| let entry = MetaAttached { | ||||
| inner: t.into(), | ||||
| meta: EntryMeta::new(), | ||||
| }; | ||||
| entry_tx.send(entry).await.unwrap(); | ||||
| } | ||||
| Err(err) => eprintln!("Error: {err:?}"), | ||||
|
|
@@ -139,7 +155,26 @@ impl RepoHandler for ImportRepo { | |||
| // TODO handle storage type | ||||
| let data = m.data.unwrap_or_default(); | ||||
| let b: Blob = Blob::from_content_bytes(data); | ||||
| let entry: Entry = b.into(); | ||||
| // let blob_with_data = storage.get_blobs_by_hashes(repo_id,vec![b.id.to_string()]).await?.iter().next().unwrap(); | ||||
|
||||
| // let blob_with_data = storage.get_blobs_by_hashes(repo_id,vec![b.id.to_string()]).await?.iter().next().unwrap(); |
Copilot
AI
Nov 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove commented-out code on line 401. If this code might be needed later, document why with a TODO comment or remove it entirely as it's captured in version control.
| //let (current_head, refs) = self.head_hash().await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 36 has an extra leading space before
git-internal. The alignment should match the surrounding lines (no leading space).