Skip to content

Commit 3beb12a

Browse files
feat(hooks): pass more context via hooks init function
1 parent f030d95 commit 3beb12a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

cmd/semantic-release/main.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ func cliHandler(cmd *cobra.Command, args []string) {
9797

9898
ci, err := pluginManager.GetCICondition()
9999
exitIfError(err)
100-
logger.Printf("ci-condition plugin: %s@%s\n", ci.Name(), ci.Version())
100+
ciName := ci.Name()
101+
logger.Printf("ci-condition plugin: %s@%s\n", ciName, ci.Version())
101102

102103
prov, err := pluginManager.GetProvider()
103104
exitIfError(err)
104-
logger.Printf("provider plugin: %s@%s\n", prov.Name(), prov.Version())
105+
provName := prov.Name()
106+
logger.Printf("provider plugin: %s@%s\n", provName, prov.Version())
105107

106108
if conf.ProviderOpts["token"] == "" {
107109
conf.ProviderOpts["token"] = conf.Token
@@ -143,7 +145,18 @@ func cliHandler(cmd *cobra.Command, args []string) {
143145
logger.Printf("hooks plugins: %s\n", strings.Join(hooksNames, ", "))
144146
}
145147

146-
exitIfError(hooksExecutor.Init(conf.HooksOpts))
148+
hooksConfig := map[string]string{
149+
"provider": provName,
150+
"ci": ciName,
151+
"currentBranch": currentBranch,
152+
"currentSha": currentSha,
153+
"defaultBranch": repoInfo.DefaultBranch,
154+
"prerelease": fmt.Sprintf("%t", conf.Prerelease),
155+
}
156+
for k, v := range conf.HooksOpts {
157+
hooksConfig[k] = v
158+
}
159+
exitIfError(hooksExecutor.Init(hooksConfig))
147160

148161
if !conf.NoCI {
149162
logger.Println("running CI condition...")

0 commit comments

Comments
 (0)