Skip to content

Commit 445bfb3

Browse files
markbtfacebook-github-bot
authored andcommitted
tools/admin: print missing parts of cross-repo configs
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
1 parent 99ac1de commit 445bfb3

File tree

2 files changed

+102
-21
lines changed

2 files changed

+102
-21
lines changed

eden/mononoke/tests/integration/newadmin/test-admin-cross-repo-config.t

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,37 @@ setup configerator configs
1818
$ mononoke_admin cross-repo-config -R repo list --with-contents
1919
TEST_VERSION_NAME:
2020
large repo: 0
21-
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
21+
common pushrebase bookmarks: ["master_bookmark"]
2222
version name: TEST_VERSION_NAME
23-
small repo: 1
23+
small repo: 1
2424
default action: Preserve
2525
prefix map:
2626
arvr->.fbsource-rest/arvr
27-
small repo: 2
27+
submodule action: Strip
28+
small repo: 2
2829
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
2930
prefix map:
3031
arvr->arvr
3132
fbandroid->.ovrsource-rest/fbandroid
3233
fbcode->.ovrsource-rest/fbcode
3334
fbobjc->.ovrsource-rest/fbobjc
3435
xplat->.ovrsource-rest/xplat
36+
submodule action: Strip
3537

3638

3739
TEST_VERSION_NAME_COMPLEX:
3840
large repo: 0
39-
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
41+
common pushrebase bookmarks: ["master_bookmark"]
4042
version name: TEST_VERSION_NAME_COMPLEX
41-
small repo: 1
43+
small repo: 1
4244
default action: Preserve
4345
prefix map:
4446
a/b/c1->ma/b/c1
4547
a/b/c2->ma/b/c2
4648
arvr->.fbsource-rest/arvr
4749
d/e->ma/b/c2/d/e
48-
small repo: 2
50+
submodule action: Strip
51+
small repo: 2
4952
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
5053
prefix map:
5154
a/b/c1->ma/b/c1
@@ -56,39 +59,52 @@ setup configerator configs
5659
fbcode->.ovrsource-rest/fbcode
5760
fbobjc->.ovrsource-rest/fbobjc
5861
xplat->.ovrsource-rest/xplat
62+
submodule action: Strip
5963

6064

6165
TEST_VERSION_NAME_OLD:
6266
large repo: 0
63-
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
67+
common pushrebase bookmarks: ["master_bookmark"]
6468
version name: TEST_VERSION_NAME_OLD
65-
small repo: 1
69+
small repo: 1
6670
default action: Preserve
6771
prefix map:
6872
arvr->.fbsource-rest/arvr_old
69-
small repo: 2
73+
submodule action: Strip
74+
small repo: 2
7075
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
7176
prefix map:
7277
arvr->arvr
7378
fbandroid->.ovrsource-rest/fbandroid
7479
fbcode->.ovrsource-rest/fbcode_old
7580
fbobjc->.ovrsource-rest/fbobjc
7681
xplat->.ovrsource-rest/xplat
82+
submodule action: Strip
7783

7884

7985
$ mononoke_admin cross-repo-config -R repo by-version TEST_VERSION_NAME_OLD
8086
large repo: 0
81-
common pushrebase bookmarks: [BookmarkKey { name: BookmarkName { bookmark: "master_bookmark" }, category: Branch }]
87+
common pushrebase bookmarks: ["master_bookmark"]
8288
version name: TEST_VERSION_NAME_OLD
83-
small repo: 1
89+
small repo: 1
8490
default action: Preserve
8591
prefix map:
8692
arvr->.fbsource-rest/arvr_old
87-
small repo: 2
93+
submodule action: Strip
94+
small repo: 2
8895
default action: PrependPrefix(NonRootMPath("arvr-legacy"))
8996
prefix map:
9097
arvr->arvr
9198
fbandroid->.ovrsource-rest/fbandroid
9299
fbcode->.ovrsource-rest/fbcode_old
93100
fbobjc->.ovrsource-rest/fbobjc
94101
xplat->.ovrsource-rest/xplat
102+
submodule action: Strip
103+
104+
$ mononoke_admin cross-repo-config -R repo common
105+
large repo: 0
106+
common pushrebase bookmarks: ["master_bookmark"]
107+
small repo: 1
108+
bookmark prefix: fbsource/
109+
small repo: 2
110+
bookmark prefix: ovrsource/

eden/mononoke/tools/admin/src/commands/cross_repo_config.rs

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use context::CoreContext;
1313
use itertools::Itertools;
1414
use metaconfig_types::CommitSyncConfig;
1515
use metaconfig_types::CommitSyncConfigVersion;
16+
use metaconfig_types::DEFAULT_GIT_SUBMODULE_METADATA_FILE_PREFIX;
1617
use mononoke_app::args::RepoArgs;
1718
use mononoke_app::MononokeApp;
1819
use repo_cross_repo::RepoCrossRepo;
@@ -36,6 +37,8 @@ pub enum ConfigSubcommand {
3637
ByVersion(ByVersionArgs),
3738
/// List all available CommitSyncConfig versions for the repo
3839
List(ListArgs),
40+
/// Show common config
41+
Common,
3942
}
4043

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

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

116+
async fn common(_ctx: &CoreContext, repo: &Repo) -> Result<()> {
117+
let common_config = repo
118+
.repo_cross_repo()
119+
.live_commit_sync_config()
120+
.get_common_config(repo.repo_identity().id())?;
121+
println!("large repo: {}", common_config.large_repo_id);
122+
println!(
123+
"common pushrebase bookmarks: {:?}",
124+
common_config
125+
.common_pushrebase_bookmarks
126+
.iter()
127+
.map(ToString::to_string)
128+
.collect::<Vec<_>>()
129+
);
130+
for (small_repo_id, small_repo_config) in common_config
131+
.small_repos
132+
.into_iter()
133+
.sorted_by_key(|(small_repo_id, _)| *small_repo_id)
134+
{
135+
println!("small repo: {}", small_repo_id);
136+
println!(" bookmark prefix: {}", small_repo_config.bookmark_prefix);
137+
if !small_repo_config.common_pushrebase_bookmarks_map.is_empty() {
138+
println!(" common pushrebase bookmarks map:");
139+
for (k, v) in small_repo_config.common_pushrebase_bookmarks_map.iter() {
140+
println!(" {} => {}", k, v);
141+
}
142+
}
143+
}
144+
Ok(())
145+
}
146+
112147
fn print_commit_sync_config(csc: CommitSyncConfig, line_prefix: &str) {
113148
println!("{}large repo: {}", line_prefix, csc.large_repo_id);
114149
println!(
115150
"{}common pushrebase bookmarks: {:?}",
116-
line_prefix, csc.common_pushrebase_bookmarks
151+
line_prefix,
152+
csc.common_pushrebase_bookmarks
153+
.iter()
154+
.map(ToString::to_string)
155+
.collect::<Vec<_>>(),
117156
);
118157
println!("{}version name: {}", line_prefix, csc.version_name);
119158
for (small_repo_id, small_repo_config) in csc
120159
.small_repos
121160
.into_iter()
122161
.sorted_by_key(|(small_repo_id, _)| *small_repo_id)
123162
{
124-
println!("{} small repo: {}", line_prefix, small_repo_id);
163+
println!("{}small repo: {}", line_prefix, small_repo_id);
125164
println!(
126165
"{} default action: {:?}",
127166
line_prefix, small_repo_config.default_action
128167
);
129-
println!("{} prefix map:", line_prefix);
130-
for (from, to) in small_repo_config
131-
.map
132-
.into_iter()
133-
.sorted_by_key(|(from, _)| from.clone())
134-
{
135-
println!("{} {}->{}", line_prefix, from, to);
168+
if !small_repo_config.map.is_empty() {
169+
println!("{} prefix map:", line_prefix);
170+
for (from, to) in small_repo_config
171+
.map
172+
.into_iter()
173+
.sorted_by_key(|(from, _)| from.clone())
174+
{
175+
println!("{} {}->{}", line_prefix, from, to);
176+
}
177+
}
178+
let submodule_config = &small_repo_config.submodule_config;
179+
println!(
180+
"{} submodule action: {:?}",
181+
line_prefix, submodule_config.git_submodules_action,
182+
);
183+
let file_prefix = &submodule_config.submodule_metadata_file_prefix;
184+
if file_prefix != DEFAULT_GIT_SUBMODULE_METADATA_FILE_PREFIX {
185+
println!(
186+
"{} submodule metadata file prefix: {:?}",
187+
line_prefix, file_prefix
188+
);
189+
}
190+
if !submodule_config.submodule_dependencies.is_empty() {
191+
println!("{} submodule dependencies:", line_prefix);
192+
for (path, repo_id) in submodule_config.submodule_dependencies.iter() {
193+
println!("{} {} => {}", line_prefix, path, repo_id);
194+
}
195+
}
196+
if !submodule_config.dangling_submodule_pointers.is_empty() {
197+
println!("{} dangling submodule pointers:", line_prefix);
198+
for pointer in submodule_config.dangling_submodule_pointers.iter() {
199+
println!("{} {}", line_prefix, pointer);
200+
}
136201
}
137202
}
138203
}

0 commit comments

Comments
 (0)