Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
R
RBM
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 16
    • Issues 16
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 2
    • Merge Requests 2
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards

GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

  • The Tor Project
  • Applications
  • RBM
  • Issues
  • #40012

Closed
Open
Opened Jan 12, 2021 by Matthew Finkel@sysrqbDeveloper

Add a `safe_c` template subroutine

Currently, we have a c() subroutine for obtaining configuration variables, however if the requested variable is not defined then this subroutine returns "". In many cases, we would prefer a build failure when a requested variable is not set, instead of continuing while using the empty string.

I believe we can define another subroutine that is the same as c() except it sets error_if_undef => 1. As a placeholder name, let's call this new subroutine safe_c. c is nice because it is short, we already have pc defined, as well. Maybe we should call this proposed subroutine sc.

My untested proposed patch is:

diff --git a/lib/RBM.pm b/lib/RBM.pm
index 074e385..bec5a30 100644
--- a/lib/RBM.pm
+++ b/lib/RBM.pm
@@ -652,6 +652,7 @@ sub process_template {
         project    => $project,
         p          => $config->{projects}{$project},
         c          => sub { project_config($project, @_) },
+        safe_c     => sub { project_config($project, @_, { error_if_undef => 1 }) },
         pc         => sub {
             my @args = @_;
             $args[2] = { $_[2] ? %{$_[2]} : (), origin_project => $project };
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Tor Browser: unspecified
Milestone
Tor Browser: unspecified
Assign milestone
Time tracking
None
Due date
None
Reference: tpo/applications/rbm#40012