Skip to content

Commit

Permalink
feat: include working directory within hook environment variables (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
purpleclay authored Aug 29, 2024
1 parent 577f3fe commit bb68167
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,17 @@ Environment Variables:
| | Must be used in conjunction with NSV_SHOW (default: full) |
| NSV_SHOW | show how the next semantic version was generated |
| NSV_TAG_MESSAGE | a custom message for the annotated tag, supports go text |
| | templates. The default is: "chore: tagged release {{.Tag}}" |`
| | templates. The default is: "chore: tagged release {{.Tag}}" |
Hook Environment Variables:
| Name | Description |
|-----------------------|-------------------------------------------------------------|
| NSV_NEXT_TAG | the next calculated semantic version |
| NSV_PREV_TAG | the last semantic version as identified within the tag |
| | history of the current repository |
| NSV_WORKING_DIRECTORY | the working directory (or path) relative to the root of the |
| | current repository. It will be empty if not a monorepo |`
)

func tagCmd(opts *Options) *cobra.Command {
Expand Down
6 changes: 5 additions & 1 deletion internal/nsv/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ func NextVersion(gitc *git.Client, opts Options) (*Next, error) {
if diffs, err = execHook(
gitc,
opts.Hook,
[]string{"NSV_PREV_TAG=" + ltag, "NSV_NEXT_TAG=" + nextVer},
[]string{
"NSV_PREV_TAG=" + ltag,
"NSV_NEXT_TAG=" + nextVer,
"NSV_WORKING_DIRECTORY=" + ctx.LogPath,
},
opts.Logger,
); err != nil {
return nil, err
Expand Down

0 comments on commit bb68167

Please sign in to comment.