@@ -13,6 +13,7 @@ use context::CoreContext;
1313use itertools:: Itertools ;
1414use metaconfig_types:: CommitSyncConfig ;
1515use metaconfig_types:: CommitSyncConfigVersion ;
16+ use metaconfig_types:: DEFAULT_GIT_SUBMODULE_METADATA_FILE_PREFIX ;
1617use mononoke_app:: args:: RepoArgs ;
1718use mononoke_app:: MononokeApp ;
1819use 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+
112147fn 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