Skip to content

Commit

Permalink
feat(hooks): pass more context via hooks init function
Browse files Browse the repository at this point in the history
  • Loading branch information
christophwitzko committed Jan 26, 2022
1 parent f030d95 commit 3beb12a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cmd/semantic-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ func cliHandler(cmd *cobra.Command, args []string) {

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

prov, err := pluginManager.GetProvider()
exitIfError(err)
logger.Printf("provider plugin: %s@%s\n", prov.Name(), prov.Version())
provName := prov.Name()
logger.Printf("provider plugin: %s@%s\n", provName, prov.Version())

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

exitIfError(hooksExecutor.Init(conf.HooksOpts))
hooksConfig := map[string]string{
"provider": provName,
"ci": ciName,
"currentBranch": currentBranch,
"currentSha": currentSha,
"defaultBranch": repoInfo.DefaultBranch,
"prerelease": fmt.Sprintf("%t", conf.Prerelease),
}
for k, v := range conf.HooksOpts {
hooksConfig[k] = v
}
exitIfError(hooksExecutor.Init(hooksConfig))

if !conf.NoCI {
logger.Println("running CI condition...")
Expand Down

0 comments on commit 3beb12a

Please sign in to comment.