diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-01-22 00:00:00 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-01-22 00:00:00 +0000 |
| commit | 675d44b8349078f2d231ca37a1621254a4c50ab5 (patch) | |
| tree | 784286231dc6fade15266a6327b58daffe5bb1c8 /src/git.rs | |
| parent | 9200b96bd8fe7ac254e41048790d7411937c3f95 (diff) | |
feat(git) save pgp sig in patch event
so that commit ids can be maintained
Diffstat (limited to 'src/git.rs')
| -rw-r--r-- | src/git.rs | 17 |
1 files changed, 17 insertions, 0 deletions
| @@ -53,6 +53,7 @@ pub trait RepoActions { | |||
| 53 | latest_commit: &Sha1Hash, | 53 | latest_commit: &Sha1Hash, |
| 54 | ) -> Result<(Vec<Sha1Hash>, Vec<Sha1Hash>)>; | 54 | ) -> Result<(Vec<Sha1Hash>, Vec<Sha1Hash>)>; |
| 55 | fn make_patch_from_commit(&self, commit: &Sha1Hash) -> Result<String>; | 55 | fn make_patch_from_commit(&self, commit: &Sha1Hash) -> Result<String>; |
| 56 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String>; | ||
| 56 | fn checkout(&self, ref_name: &str) -> Result<Sha1Hash>; | 57 | fn checkout(&self, ref_name: &str) -> Result<Sha1Hash>; |
| 57 | fn create_branch_at_commit(&self, branch_name: &str, commit: &str) -> Result<()>; | 58 | fn create_branch_at_commit(&self, branch_name: &str, commit: &str) -> Result<()>; |
| 58 | fn apply_patch_chain( | 59 | fn apply_patch_chain( |
| @@ -225,6 +226,22 @@ impl RepoActions for Repo { | |||
| 225 | .to_owned()) | 226 | .to_owned()) |
| 226 | } | 227 | } |
| 227 | 228 | ||
| 229 | fn extract_commit_pgp_signature(&self, commit: &Sha1Hash) -> Result<String> { | ||
| 230 | let oid = Oid::from_bytes(commit.as_byte_array()).context(format!( | ||
| 231 | "failed to convert commit_id format for {}", | ||
| 232 | &commit | ||
| 233 | ))?; | ||
| 234 | |||
| 235 | let (sign, _data) = self | ||
| 236 | .git_repo | ||
| 237 | .extract_signature(&oid, None) | ||
| 238 | .context("failed to extract signature - perhaps there is no signature?")?; | ||
| 239 | |||
| 240 | Ok(std::str::from_utf8(&sign) | ||
| 241 | .context("commit signature cannot be converted to a utf8 string")? | ||
| 242 | .to_owned()) | ||
| 243 | } | ||
| 244 | |||
| 228 | fn get_commits_ahead_behind( | 245 | fn get_commits_ahead_behind( |
| 229 | &self, | 246 | &self, |
| 230 | base_commit: &Sha1Hash, | 247 | base_commit: &Sha1Hash, |