Skip to content

Commit

Permalink
Update GitUploader trait to use Option<ChangesetId> instead of Change…
Browse files Browse the repository at this point in the history
…setId

Summary: Follow up of the previous diff, it changes the trait itself so we use `Option<ChangesetId>` to lowest layers possible. We can't go any further with `Option<ChangesetId>` because the thrift structures will change in a non-compatible way (especially for `BonsaiTagTarget`)

Reviewed By: gustavoavena

Differential Revision: D68438894

fbshipit-source-id: 2a96fda86f244fa70855dec5983658b4970c9c7a
  • Loading branch information
RajivTS authored and facebook-github-bot committed Jan 21, 2025
1 parent c0c41f6 commit effe32f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
5 changes: 4 additions & 1 deletion eden/mononoke/git/import_direct/src/uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use mononoke_api::repo::upload_non_blob_git_object;
use mononoke_types::bonsai_changeset::BonsaiAnnotatedTag;
use mononoke_types::bonsai_changeset::BonsaiAnnotatedTagTarget;
use mononoke_types::hash;
use mononoke_types::hash::Blake2;
use mononoke_types::BonsaiChangeset;
use mononoke_types::ChangesetId;
use mononoke_types::FileChange;
Expand Down Expand Up @@ -182,9 +183,11 @@ where
async fn generate_changeset_for_annotated_tag(
&self,
ctx: &CoreContext,
target_changeset_id: ChangesetId,
target_changeset_id: Option<ChangesetId>,
mut tag: TagMetadata,
) -> Result<ChangesetId, Error> {
let target_changeset_id = target_changeset_id
.unwrap_or_else(|| ChangesetId::new(Blake2::from_byte_array([0; 32])));
let annotated_tag = BonsaiAnnotatedTag {
target: BonsaiAnnotatedTagTarget::Changeset(target_changeset_id),
pgp_signature: tag.pgp_signature.take(),
Expand Down
2 changes: 1 addition & 1 deletion eden/mononoke/git/import_tools/src/git_uploader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ pub trait GitUploader: Clone + Send + Sync + 'static {
async fn generate_changeset_for_annotated_tag(
&self,
ctx: &CoreContext,
target_changeset_id: ChangesetId,
target_changeset_id: Option<ChangesetId>,
tag: TagMetadata,
) -> Result<ChangesetId, Error>;

Expand Down
1 change: 0 additions & 1 deletion eden/mononoke/git/import_tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ pub async fn create_changeset_for_annotated_tag<Uploader: GitUploader, Reader: G
.await
.with_context(|| format_err!("Failed to create TagMetadata from git tag {}", tag_id))?;
// Create the corresponding changeset for the Git Tag at Mononoke end
let original_changeset_id = original_changeset_id.unwrap_or_else(ChangesetId::empty);
let changeset_id = uploader
.generate_changeset_for_annotated_tag(ctx, original_changeset_id, tag_metadata)
.await
Expand Down
6 changes: 0 additions & 6 deletions eden/mononoke/mononoke_types/src/typed_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ where
#[derive(mysql::OptTryFromRowField)]
pub struct ChangesetId(Blake2);

impl ChangesetId {
pub fn empty() -> Self {
Self(Blake2::from_byte_array([0; 32]))
}
}

/// An identifier for a changeset hash prefix in Mononoke.
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Abomonation)]
pub struct ChangesetIdPrefix(Blake2Prefix);
Expand Down

0 comments on commit effe32f

Please sign in to comment.