Skip to content

Commit

Permalink
add govdao to make release changes
Browse files Browse the repository at this point in the history
  • Loading branch information
leohhhn committed Feb 11, 2025
1 parent 78fb899 commit 6710db2
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions examples/gno.land/r/gnoland/users/users.gno
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
package users

import (
"regexp"
"std"
"strings"

"gno.land/p/demo/dao"
"gno.land/p/demo/releases"
)

var (
changelog = releases.NewChangelog("r/gnoland/users")
reValidPath = regexp.MustCompile(`^gno\.land/r/gnoland/users/v[^/]+$`)
"gno.land/r/gov/dao/bridge"
)

var changelog = releases.NewChangelog("r/gnoland/users")

const usersPrefix = "gno.land/r/gnoland/users/"

func init() {
changelog.NewRelease("v1", "/r/gnoland/users/v1", "[Original PR](https://github.com/gnolang/gno/pull/3166)")
}

// AddRelease is intended to be called via a `r/gnoland/user/v*`'s init().
func AddRelease(note string) {
callerPkgPath := std.PrevRealm().PkgPath()
if !reValidPath.MatchString(callerPkgPath) {
return
func Render(_ string) string {
return changelog.RenderAsTable(10)
}

// NewAddReleaseExecutor allows a GovDAO proposal to add a release to the changelog
func NewAddReleaseExecutor(newVerPkgPath, note string) dao.Executor {
if !strings.HasPrefix(newVerPkgPath, usersPrefix) {
panic("invalid version pkgpath")
}

ver := strings.TrimPrefix(callerPkgPath, "gno.land/r/gnoland/users/")
changelog.NewRelease(ver, strings.TrimPrefix(callerPkgPath, "gno.land"), note)
}
cb := func() error {
ver := strings.TrimPrefix(newVerPkgPath, usersPrefix)
changelog.NewRelease(ver, strings.TrimPrefix(newVerPkgPath, "gno.land"), note)
return nil
}

func Render(_ string) string {
return changelog.RenderAsTable(10)
return bridge.GovDAO().NewGovDAOExecutor(cb)
}

0 comments on commit 6710db2

Please sign in to comment.