Skip to content

Commit

Permalink
tools/admin: print missing parts of cross-repo configs
Browse files Browse the repository at this point in the history
Summary: The admin command for printing cross-repo config is missing the newly added Git submodule expansion fields.  Add them to the output, as well as a new command for printing the common config.

Reviewed By: RajivTS

Differential Revision: D67735987

fbshipit-source-id: a90b29e9bd821bda0eec1c5102805ce4966d041a
  • Loading branch information
markbt authored and facebook-github-bot committed Dec 31, 2024
1 parent 99ac1de commit 445bfb3
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@ setup configerator configs
$ mononoke_admin cross-repo-config -R repo list --with-contents
TEST_VERSION_NAME:
large repo: 0
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
common pushrebase bookmarks: ["master_bookmark"]
version name: TEST_VERSION_NAME
small repo: 1
small repo: 1
default action: Preserve
prefix map:
arvr->.fbsource-rest/arvr
small repo: 2
submodule action: Strip
small repo: 2
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
prefix map:
arvr->arvr
fbandroid->.ovrsource-rest/fbandroid
fbcode->.ovrsource-rest/fbcode
fbobjc->.ovrsource-rest/fbobjc
xplat->.ovrsource-rest/xplat
submodule action: Strip


TEST_VERSION_NAME_COMPLEX:
large repo: 0
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
common pushrebase bookmarks: ["master_bookmark"]
version name: TEST_VERSION_NAME_COMPLEX
small repo: 1
small repo: 1
default action: Preserve
prefix map:
a/b/c1->ma/b/c1
a/b/c2->ma/b/c2
arvr->.fbsource-rest/arvr
d/e->ma/b/c2/d/e
small repo: 2
submodule action: Strip
small repo: 2
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
prefix map:
a/b/c1->ma/b/c1
Expand All @@ -56,39 +59,52 @@ setup configerator configs
fbcode->.ovrsource-rest/fbcode
fbobjc->.ovrsource-rest/fbobjc
xplat->.ovrsource-rest/xplat
submodule action: Strip


TEST_VERSION_NAME_OLD:
large repo: 0
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
common pushrebase bookmarks: ["master_bookmark"]
version name: TEST_VERSION_NAME_OLD
small repo: 1
small repo: 1
default action: Preserve
prefix map:
arvr->.fbsource-rest/arvr_old
small repo: 2
submodule action: Strip
small repo: 2
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
prefix map:
arvr->arvr
fbandroid->.ovrsource-rest/fbandroid
fbcode->.ovrsource-rest/fbcode_old
fbobjc->.ovrsource-rest/fbobjc
xplat->.ovrsource-rest/xplat
submodule action: Strip


$ mononoke_admin cross-repo-config -R repo by-version TEST_VERSION_NAME_OLD
large repo: 0
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
common pushrebase bookmarks: ["master_bookmark"]
version name: TEST_VERSION_NAME_OLD
small repo: 1
small repo: 1
default action: Preserve
prefix map:
arvr->.fbsource-rest/arvr_old
small repo: 2
submodule action: Strip
small repo: 2
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
prefix map:
arvr->arvr
fbandroid->.ovrsource-rest/fbandroid
fbcode->.ovrsource-rest/fbcode_old
fbobjc->.ovrsource-rest/fbobjc
xplat->.ovrsource-rest/xplat
submodule action: Strip

$ mononoke_admin cross-repo-config -R repo common
large repo: 0
common pushrebase bookmarks: ["master_bookmark"]
small repo: 1
bookmark prefix: fbsource/
small repo: 2
bookmark prefix: ovrsource/
83 changes: 74 additions & 9 deletions eden/mononoke/tools/admin/src/commands/cross_repo_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use context::CoreContext;
use itertools::Itertools;
use metaconfig_types::CommitSyncConfig;
use metaconfig_types::CommitSyncConfigVersion;
use metaconfig_types::DEFAULT_GIT_SUBMODULE_METADATA_FILE_PREFIX;
use mononoke_app::args::RepoArgs;
use mononoke_app::MononokeApp;
use repo_cross_repo::RepoCrossRepo;
Expand All @@ -36,6 +37,8 @@ pub enum ConfigSubcommand {
ByVersion(ByVersionArgs),
/// List all available CommitSyncConfig versions for the repo
List(ListArgs),
/// Show common config
Common,
}

#[derive(Args)]
Expand Down Expand Up @@ -68,6 +71,7 @@ pub async fn run(app: MononokeApp, args: CommandArgs) -> Result<()> {
match args.subcommand {
ConfigSubcommand::ByVersion(args) => by_version(&ctx, &repo, args).await,
ConfigSubcommand::List(args) => list(&ctx, &repo, args).await,
ConfigSubcommand::Common => common(&ctx, &repo).await,
}
}

Expand Down Expand Up @@ -109,30 +113,91 @@ async fn list(_ctx: &CoreContext, repo: &Repo, args: ListArgs) -> Result<()> {
Ok(())
}

async fn common(_ctx: &CoreContext, repo: &Repo) -> Result<()> {
let common_config = repo
.repo_cross_repo()
.live_commit_sync_config()
.get_common_config(repo.repo_identity().id())?;
println!("large repo: {}", common_config.large_repo_id);
println!(
"common pushrebase bookmarks: {:?}",
common_config
.common_pushrebase_bookmarks
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>()
);
for (small_repo_id, small_repo_config) in common_config
.small_repos
.into_iter()
.sorted_by_key(|(small_repo_id, _)| *small_repo_id)
{
println!("small repo: {}", small_repo_id);
println!(" bookmark prefix: {}", small_repo_config.bookmark_prefix);
if !small_repo_config.common_pushrebase_bookmarks_map.is_empty() {
println!(" common pushrebase bookmarks map:");
for (k, v) in small_repo_config.common_pushrebase_bookmarks_map.iter() {
println!(" {} => {}", k, v);
}
}
}
Ok(())
}

fn print_commit_sync_config(csc: CommitSyncConfig, line_prefix: &str) {
println!("{}large repo: {}", line_prefix, csc.large_repo_id);
println!(
"{}common pushrebase bookmarks: {:?}",
line_prefix, csc.common_pushrebase_bookmarks
line_prefix,
csc.common_pushrebase_bookmarks
.iter()
.map(ToString::to_string)
.collect::<Vec<_>>(),
);
println!("{}version name: {}", line_prefix, csc.version_name);
for (small_repo_id, small_repo_config) in csc
.small_repos
.into_iter()
.sorted_by_key(|(small_repo_id, _)| *small_repo_id)
{
println!("{} small repo: {}", line_prefix, small_repo_id);
println!("{}small repo: {}", line_prefix, small_repo_id);
println!(
"{} default action: {:?}",
line_prefix, small_repo_config.default_action
);
println!("{} prefix map:", line_prefix);
for (from, to) in small_repo_config
.map
.into_iter()
.sorted_by_key(|(from, _)| from.clone())
{
println!("{} {}->{}", line_prefix, from, to);
if !small_repo_config.map.is_empty() {
println!("{} prefix map:", line_prefix);
for (from, to) in small_repo_config
.map
.into_iter()
.sorted_by_key(|(from, _)| from.clone())
{
println!("{} {}->{}", line_prefix, from, to);
}
}
let submodule_config = &small_repo_config.submodule_config;
println!(
"{} submodule action: {:?}",
line_prefix, submodule_config.git_submodules_action,
);
let file_prefix = &submodule_config.submodule_metadata_file_prefix;
if file_prefix != DEFAULT_GIT_SUBMODULE_METADATA_FILE_PREFIX {
println!(
"{} submodule metadata file prefix: {:?}",
line_prefix, file_prefix
);
}
if !submodule_config.submodule_dependencies.is_empty() {
println!("{} submodule dependencies:", line_prefix);
for (path, repo_id) in submodule_config.submodule_dependencies.iter() {
println!("{} {} => {}", line_prefix, path, repo_id);
}
}
if !submodule_config.dangling_submodule_pointers.is_empty() {
println!("{} dangling submodule pointers:", line_prefix);
for pointer in submodule_config.dangling_submodule_pointers.iter() {
println!("{} {}", line_prefix, pointer);
}
}
}
}

0 comments on commit 445bfb3

Please sign in to comment.