From fbb2f502700c5e2ec7ea1dfaec9978395618e659 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Thu, 22 Oct 2026 05:31:36 +0900 Subject: [PATCH] PR source Signed-off-by: Seongmin Lee --- crates/sh_org/src/legacy/sh_tangled.rs | 16 +++++++++++-- crates/sh_org/src/migrate.rs | 32 ++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/crates/sh_org/src/legacy/sh_tangled.rs b/crates/sh_org/src/legacy/sh_tangled.rs index 01f4ac9ba..cbd6d3066 100644 --- a/crates/sh_org/src/legacy/sh_tangled.rs +++ b/crates/sh_org/src/legacy/sh_tangled.rs @@ -189,14 +189,14 @@ pub mod repo_pull { pub target_repo: Option, pub target_branch: Option, pub title: DefaultStr, + pub source: Option, + pub source_branch: Option, // we will drop these known fields pub rounds: Option>, pub patch: Option>, pub patch_blob: Option>, pub patch_blobs: Option>, pub versions: Option>, - pub source: Option>, - pub source_branch: Option>, pub head_sha: Option>, pub dependent_on: Option>, pub pull_id: Option>, @@ -214,6 +214,18 @@ pub mod repo_pull { #[serde(flatten, default, skip_serializing_if = "Option::is_none")] pub extra_data: Extra, } + + #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)] + #[serde(rename_all = "camelCase")] + pub struct Source { + pub branch: Option, + /// AtUri or Did + pub repo: Option, + pub repo_did: Option, + pub sha: Option, + #[serde(flatten, default, skip_serializing_if = "Option::is_none")] + pub extra_data: Extra, + } } pub mod repo_pull_status { diff --git a/crates/sh_org/src/migrate.rs b/crates/sh_org/src/migrate.rs index 7f8ab9b17..c1452a5fc 100644 --- a/crates/sh_org/src/migrate.rs +++ b/crates/sh_org/src/migrate.rs @@ -692,6 +692,8 @@ fn repo_issue(store: &Store, row: &Record) -> anyhow::Result { tangled_labels: None, target_branch: None, title: markdown_inline(row, issue.title), + assignees: None, + x_tngl_legacy_souce: None, extra_data: (!extra_data.is_empty()).then_some(extra_data), }, )?; @@ -813,6 +815,22 @@ fn repo_pull(store: &Store, row: &Record) -> anyhow::Result { format!("pull target repo {repo:?} has no did") })?; + let source = pull.source.unwrap_or_default(); + let source_branch = source + .branch + .or(pull.source_branch) + .filter(|branch| !branch.is_empty()); + let source_repo = match [source.repo_did, source.repo] + .into_iter() + .flatten() + .find(|value| !value.as_str().is_empty()) + { + None => Some(repo.clone()), + Some(UriValue::Did(did)) => Some(did), + Some(UriValue::At(uri)) => resolve_repo(store, &uri, Omit).ok().flatten(), + Some(_) => None, + }; + let target_branch = target .branch .or(pull.target_branch) @@ -832,8 +850,6 @@ fn repo_pull(store: &Store, row: &Record) -> anyhow::Result { // TODO: migrate blobs to new owner - // TODO: put source branch somewhere - let uri = ticket_uri(store, row, &repo)?; let state = ticket_state(store, &uri)?; let ticket = with_cid( @@ -852,6 +868,14 @@ fn repo_pull(store: &Store, row: &Record) -> anyhow::Result { tangled_labels: None, target_branch: Some(target_branch), title: markdown_inline(row, pull.title), + assignees: None, + x_tngl_legacy_souce: source_repo.zip(source_branch).map(|(repo, branch)| { + org_tangled::review::patch::Source { + repo, + branch, + extra_data: None, + } + }), extra_data: (!extra_data.is_empty()).then_some(extra_data), }, )?; @@ -884,7 +908,8 @@ fn repo_pull_status(store: &Store, row: &Record) -> anyhow::Result { Some("closed") => "closed", Some("merged") => "completed", _ => { - return Err(anyhow::anyhow!("unknown pull status {}", status.status)).context(Malformed); + return Err(anyhow::anyhow!("unknown pull status {}", status.status)) + .context(Malformed); } }; update_ticket_state(store, row, &status.pull, value) @@ -919,7 +944,6 @@ fn ticket_state(store: &Store, ticket: &AtUri) -> anyhow::Result { }) } -#[allow(dead_code)] fn string_(_store: &Store, row: &Record) -> anyhow::Result { let string_: legacy::String = serde_json::from_str(&row.sh_record)?; -- 2.54.0