
morgan pushed to branch main at The Tor Project / Applications / RBM Commits: 1b1b183f by Nicolas Vigier at 2025-06-19T15:45:19+02:00 Bug 40085: Add the "rbm show_used_projects" command - - - - - 5 changed files: - doc/Makefile - doc/documentation.asc - + doc/rbm-show_used_projects.asc - lib/RBM.pm - rbm Changes: ===================================== doc/Makefile ===================================== @@ -27,6 +27,7 @@ MAN1_ASC += rbm.asc MAN1_ASC += rbm-usage.asc MAN1_ASC += rbm-tar.asc MAN1_ASC += rbm-showconf.asc +MAN1_ASC += rbm-show_used_projects.asc MAN1_ASC += rbm-fetch.asc MAN1_ASC += rbm-build.asc ===================================== doc/documentation.asc ===================================== @@ -15,6 +15,7 @@ rbm commands : - link:rbm-usage.html[rbm-usage(1)] - link:rbm-tar.html[rbm-tar(1)] - link:rbm-showconf.html[rbm-showconf(1)] +- link:rbm-show_used_projects.html[rbm-show_used_projects(1)] - link:rbm-build.html[rbm-build(1)] - link:rbm-fetch.html[rbm-fetch(1)] ===================================== doc/rbm-show_used_projects.asc ===================================== @@ -0,0 +1,37 @@ +rbm-show_used_projects(1) +========================= + +NAME +---- +rbm-show_used_projects - Show which projects are used when processing a config option + + +SYNOPSIS +-------- +[verse] +'rbm show_used_projects' <project> <config name> [options] + +DESCRIPTION +----------- + +This command works in a similar way to showconf, but instead of printing +the selected config option, it will print the projects that were used +while processing this option. + +COMMAND LINE OPTIONS +-------------------- +See link:rbm_cli.html[rbm_cli(7)]. + +EXAMPLE +------- + +Show which projects are being used when processing the build script +from the 'release' project using the 'alpha' target: +---- +$ rbm show_used_projects release build --target alpha +---- + +SEE ALSO +-------- +link:rbm.html[rbm(1)], +link:rbm_config.html[rbm_config(7)] ===================================== lib/RBM.pm ===================================== @@ -34,6 +34,13 @@ BEGIN { our $config; +our %used_projects; +our $store_used_projects; + +sub get_used_projects { + return sort keys %used_projects; +} + sub load_config_file { my $res = {}; my @conf; @@ -243,6 +250,7 @@ sub confkey_str { sub project_config { my ($project, $name, $options) = @_; + $used_projects{$project} = 1 if $store_used_projects; CORE::state %config_cache; my $res; my $error_if_undef = $options->{error_if_undef}; ===================================== rbm ===================================== @@ -30,6 +30,10 @@ my %actions = ( run => \&show_conf, descr => 'Show configuration', }, + show_used_projects => { + run => \&show_used_projects, + descr => 'Show the list of used projects when getting a config option', + }, usage => { run => \&usage, descr => 'Show usage information for an action', @@ -104,6 +108,19 @@ sub show_conf { print ref $r ? YAML::XS::Dump($r) : "$r\n"; } +sub show_used_projects { + shift; + my $args = set_options(@_); + usageexit('show_used_projects') unless @$args == 2; + my $project = shift @$args; + $RBM::store_used_projects = 1; + RBM::valid_project($project); + my $r = RBM::project_config($project, @$args); + RBM::exit_error "Undefined" unless defined $r; + my @usedprojects = RBM::get_used_projects; + print join("\n", @usedprojects), "\n"; +} + sub fetch { shift; $RBM::config->{run}{fetch} = 1; View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/commit/1b1b183f85b36029... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/rbm/-/commit/1b1b183f85b36029... You're receiving this email because of your account on gitlab.torproject.org.