diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-16 20:41:59 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-02-16 20:41:59 +0000 |
| commit | a645273433fe3a716dd9c43ad9276da066af6127 (patch) | |
| tree | 942e08c7de68112975269b64b6802dcfcb7c1fe0 /src/git.rs | |
| parent | 614d2c8a3a0ac01b142aa83a142fc34d1ad56e9d (diff) | |
refactor: remove reliance on 'commit' tag
as part of nip34 compliance
Diffstat (limited to 'src/git.rs')
| -rw-r--r-- | src/git.rs | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -6,7 +6,7 @@ use anyhow::{bail, Context, Result}; | |||
| 6 | use git2::{DiffOptions, Oid, Revwalk}; | 6 | use git2::{DiffOptions, Oid, Revwalk}; |
| 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; | 7 | use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; |
| 8 | 8 | ||
| 9 | use crate::sub_commands::list::tag_value; | 9 | use crate::sub_commands::list::{get_commit_id_from_patch, tag_value}; |
| 10 | 10 | ||
| 11 | pub struct Repo { | 11 | pub struct Repo { |
| 12 | git_repo: git2::Repository, | 12 | git_repo: git2::Repository, |
| @@ -363,7 +363,7 @@ impl RepoActions for Repo { | |||
| 363 | .into_iter() | 363 | .into_iter() |
| 364 | .filter(|e| { | 364 | .filter(|e| { |
| 365 | !self | 365 | !self |
| 366 | .does_commit_exist(&tag_value(e, "commit").unwrap()) | 366 | .does_commit_exist(&get_commit_id_from_patch(e).unwrap()) |
| 367 | .unwrap() | 367 | .unwrap() |
| 368 | }) | 368 | }) |
| 369 | .collect(); | 369 | .collect(); |
| @@ -517,7 +517,10 @@ fn apply_patch(git_repo: &Repo, patch: &nostr::Event) -> Result<()> { | |||
| 517 | git2::ResetType::Mixed, | 517 | git2::ResetType::Mixed, |
| 518 | None, | 518 | None, |
| 519 | )?; | 519 | )?; |
| 520 | if gpg_commit_id.to_string().eq(&tag_value(patch, "commit")?) { | 520 | if gpg_commit_id |
| 521 | .to_string() | ||
| 522 | .eq(&get_commit_id_from_patch(patch)?) | ||
| 523 | { | ||
| 521 | return Ok(()); | 524 | return Ok(()); |
| 522 | } | 525 | } |
| 523 | } else { | 526 | } else { |
| @@ -575,12 +578,12 @@ fn validate_patch_applied(git_repo: &Repo, patch: &nostr::Event) -> Result<()> { | |||
| 575 | 578 | ||
| 576 | if !updated_commit_oid | 579 | if !updated_commit_oid |
| 577 | .to_string() | 580 | .to_string() |
| 578 | .eq(&tag_value(patch, "commit")?) | 581 | .eq(&get_commit_id_from_patch(patch)?) |
| 579 | { | 582 | { |
| 580 | bail!( | 583 | bail!( |
| 581 | "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", | 584 | "when applied the patch commit id ({}) doesn't match the one specified in the event tag ({})", |
| 582 | updated_commit_oid.to_string(), | 585 | updated_commit_oid.to_string(), |
| 583 | tag_value(patch, "commit")?, | 586 | get_commit_id_from_patch(patch)?, |
| 584 | ) | 587 | ) |
| 585 | } | 588 | } |
| 586 | } | 589 | } |