diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/git/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/git/mod.rs b/src/lib/git/mod.rs index b275b49..3d5297f 100644 --- a/src/lib/git/mod.rs +++ b/src/lib/git/mod.rs | |||
| @@ -75,6 +75,7 @@ pub trait RepoActions { | |||
| 75 | commit: &Sha1Hash, | 75 | commit: &Sha1Hash, |
| 76 | series_count: &Option<(u64, u64)>, | 76 | series_count: &Option<(u64, u64)>, |
| 77 | ) -> Result<String>; | 77 | ) -> Result<String>; |
| 78 | fn are_commits_too_big_for_patches(&self, commits: &[Sha1Hash]) -> bool; | ||
| 78 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String>; | 79 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String>; |
| 79 | fn checkout(&self, ref_name: &str) -> Result<Sha1Hash>; | 80 | fn checkout(&self, ref_name: &str) -> Result<Sha1Hash>; |
| 80 | fn create_branch_at_commit(&self, branch_name: &str, commit: &str) -> Result<()>; | 81 | fn create_branch_at_commit(&self, branch_name: &str, commit: &str) -> Result<()>; |
| @@ -380,6 +381,19 @@ impl RepoActions for Repo { | |||
| 380 | .to_owned()) | 381 | .to_owned()) |
| 381 | } | 382 | } |
| 382 | 383 | ||
| 384 | fn are_commits_too_big_for_patches(&self, commits: &[Sha1Hash]) -> bool { | ||
| 385 | commits.iter().any(|commit| { | ||
| 386 | if let Ok(patch) = self.make_patch_from_commit(commit, &None) { | ||
| 387 | patch.len() | ||
| 388 | > ((65 // max recomended patch event size specified in nip34 in kb | ||
| 389 | // allownace for nostr event wrapper (id, pubkey, tags, sig) | ||
| 390 | - 1) * 1024) | ||
| 391 | } else { | ||
| 392 | true | ||
| 393 | } | ||
| 394 | }) | ||
| 395 | } | ||
| 396 | |||
| 383 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String> { | 397 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String> { |
| 384 | let oid = Oid::from_bytes(commit.as_byte_array()).context(format!( | 398 | let oid = Oid::from_bytes(commit.as_byte_array()).context(format!( |
| 385 | "failed to convert commit_id format for {}", | 399 | "failed to convert commit_id format for {}", |