Skip to content

Commit f292768

Browse files
wyardleyshantstepanian
authored andcommitted
Skip changelog generation when changelog type is none (GoogleCloudPlatform#13216)
1 parent 15e88f4 commit f292768

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

.ci/magician/cmd/generate_downstream.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2025 Google LLC. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package cmd
217

318
import (
@@ -15,7 +30,7 @@ import (
1530
"github.com/spf13/cobra"
1631
)
1732

18-
var changelogExp = regexp.MustCompile("(?s)```release-note.*?```")
33+
var changelogExp = regexp.MustCompile("(?s)```release-note:(?P<noteType>[a-zA-Z]+).*```")
1934

2035
var gdEnvironmentVariables = [...]string{
2136
"BASE_BRANCH",
@@ -354,8 +369,11 @@ func addChangelogEntry(downstreamRepo *source.Repo, pullRequest *github.PullRequ
354369
return err
355370
}
356371
rnr.Mkdir(".changelog")
357-
if err := rnr.WriteFile(filepath.Join(".changelog", fmt.Sprintf("%d.txt", pullRequest.Number)), strings.Join(changelogExp.FindAllString(pullRequest.Body, -1), "\n")); err != nil {
358-
return err
372+
matches := changelogExp.FindStringSubmatch(pullRequest.Body)
373+
if matches != nil && matches[1] != "none" {
374+
if err := rnr.WriteFile(filepath.Join(".changelog", fmt.Sprintf("%d.txt", pullRequest.Number)), strings.Join(changelogExp.FindAllString(pullRequest.Body, -1), "\n")); err != nil {
375+
return err
376+
}
359377
}
360378
return rnr.PopDir()
361379
}

0 commit comments

Comments
 (0)