|
95 | 95 | return $vers; |
96 | 96 | } |
97 | 97 |
|
98 | | -sub applyPatchOrPrintMsgIf($$$) { |
| 98 | +sub applyPatchOrPrintMsgIf($$$;$) { |
99 | 99 | # Returns truthy if patch should be applied, otherwise prints message (once) as to why not. |
100 | | - # The patch is applied if $submoduleVers starts with $targetVers. |
| 100 | + # The patch is applied if $submoduleVers starts with $targetVers and is <= $maxVers (if provided). |
101 | 101 |
|
102 | | - my ($patchID, $specName, $targetVers) = @_; |
| 102 | + my ($patchID, $specName, $targetVers, $maxVers) = @_; |
103 | 103 | my $vers = $versions{$specName}; |
104 | 104 | my $submoduleVers = getVersFromGitmodules($specName); |
105 | 105 | my $key = $specName . $patchID; |
106 | 106 |
|
107 | 107 | return 0 if $patchMsgCount{$key} && $patchMsgCount{$key} ne 'Apply the patch'; |
108 | 108 |
|
| 109 | + if ($maxVers && $submoduleVers && $submoduleVers gt $maxVers) { |
| 110 | + print STDOUT "INFO: $0: skipping patch '$patchID' since spec '$specName' " . |
| 111 | + "submodule is at version '$submoduleVers' > '$maxVers' (patch max version); " . |
| 112 | + "the fix is likely in upstream now\n" unless $patchMsgCount{$key}; |
| 113 | + $patchMsgCount{$key}++; |
| 114 | + return 0; |
| 115 | + } |
| 116 | + |
109 | 117 | if ($submoduleVers && $submoduleVers =~ /^$targetVers/) { |
110 | 118 | print STDOUT "INFO: $0: applying patch '$patchID' since spec '$specName' " . |
111 | 119 | "submodule is at version '$submoduleVers', and it starts with the patch target '$targetVers'" . |
112 | 120 | "\n" unless $patchMsgCount{$key}; |
113 | 121 | return $patchMsgCount{$key} = 'Apply the patch'; |
114 | | - } elsif ($vers ge $targetVers) { |
| 122 | + } elsif (($maxVers && $vers gt $maxVers) || $vers ge $targetVers) { |
115 | 123 | print STDOUT "INFO: $0: patch '$patchID' is probably obsolete now that " . |
116 | 124 | "spec '$specName' is at version '$vers' >= '$targetVers' (patch target version); " . |
117 | 125 | "if so, remove the patch\n"; |
|
137 | 145 | # Call helper function that will cause the function to return early if the |
138 | 146 | # current version of the named spec (arg 2) is greater than the target |
139 | 147 | # version (arg 3). The first argument is a unique id that will be printed if |
140 | | - # the patch is outdated. Otherwise, if the patch is still relevant we fall |
141 | | - # through to the body of this patch function. |
| 148 | + # the patch is outdated. An optional 4th argument (maxVers) specifies the |
| 149 | + # upper bound - the patch won't apply if submodule version > maxVers. |
| 150 | + # Otherwise, if the patch is still relevant we fall through to the body |
| 151 | + # of this patch function. |
142 | 152 | applyPatchOrPrintMsgIf('2026-01-01-some-unique-id', 'semconv', '1.39.0-dev'); |
| 153 | + # Or with an upper bound: |
| 154 | + # applyPatchOrPrintMsgIf('2026-01-01-some-unique-id', 'semconv', '1.39.0', '1.40.0'); |
143 | 155 |
|
144 | 156 | # Give infor about the patch: |
145 | 157 | # |
|
160 | 172 | # Restrict the patch to the proper spec, and section or file: |
161 | 173 | # Note that here we replace links into semconv from the spec |
162 | 174 | $ARGV =~ m|^tmp/otel/specification/| |
163 | | - && applyPatchOrPrintMsgIf('2025-11-26-database-section-renamed-to-db', 'spec', '1.53.0'); |
| 175 | + && applyPatchOrPrintMsgIf('2025-11-26-database-section-renamed-to-db', 'spec', '1.53.0', '1.53.0'); |
164 | 176 |
|
165 | 177 | # Give infor about the patch, see: |
166 | 178 | # https://github.com/open-telemetry/opentelemetry.io/pull/8311#issue-3577941378 |
|
172 | 184 | sub patchSpec_because_of_SemConv_MetricRPCServerDurationRenamedToMetricRPCServerCallDuration() { |
173 | 185 | return unless |
174 | 186 | $ARGV =~ m|^tmp/otel/specification/| |
175 | | - && applyPatchOrPrintMsgIf('2025-12-05-metric-rpc-server-duration-renamed-to-rpc-server-call-duration', 'spec', '1.53.0'); |
| 187 | + && applyPatchOrPrintMsgIf('2025-12-05-metric-rpc-server-duration-renamed-to-rpc-server-call-duration', 'spec', '1.53.0', '1.53.0'); |
176 | 188 |
|
177 | 189 | # Give infor about the patch, see: |
178 | 190 | # https://github.com/open-telemetry/opentelemetry-specification/pull/4778 |
|
0 commit comments