Skip to content

Commit 6710db2

Browse files
committed
add govdao to make release changes
1 parent 78fb899 commit 6710db2

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,37 @@
11
package users
22

33
import (
4-
"regexp"
5-
"std"
64
"strings"
75

6+
"gno.land/p/demo/dao"
87
"gno.land/p/demo/releases"
9-
)
108

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

12+
var changelog = releases.NewChangelog("r/gnoland/users")
13+
14+
const usersPrefix = "gno.land/r/gnoland/users/"
15+
1616
func init() {
1717
changelog.NewRelease("v1", "/r/gnoland/users/v1", "[Original PR](https://github.com/gnolang/gno/pull/3166)")
1818
}
1919

20-
// AddRelease is intended to be called via a `r/gnoland/user/v*`'s init().
21-
func AddRelease(note string) {
22-
callerPkgPath := std.PrevRealm().PkgPath()
23-
if !reValidPath.MatchString(callerPkgPath) {
24-
return
20+
func Render(_ string) string {
21+
return changelog.RenderAsTable(10)
22+
}
23+
24+
// NewAddReleaseExecutor allows a GovDAO proposal to add a release to the changelog
25+
func NewAddReleaseExecutor(newVerPkgPath, note string) dao.Executor {
26+
if !strings.HasPrefix(newVerPkgPath, usersPrefix) {
27+
panic("invalid version pkgpath")
2528
}
2629

27-
ver := strings.TrimPrefix(callerPkgPath, "gno.land/r/gnoland/users/")
28-
changelog.NewRelease(ver, strings.TrimPrefix(callerPkgPath, "gno.land"), note)
29-
}
30+
cb := func() error {
31+
ver := strings.TrimPrefix(newVerPkgPath, usersPrefix)
32+
changelog.NewRelease(ver, strings.TrimPrefix(newVerPkgPath, "gno.land"), note)
33+
return nil
34+
}
3035

31-
func Render(_ string) string {
32-
return changelog.RenderAsTable(10)
36+
return bridge.GovDAO().NewGovDAOExecutor(cb)
3337
}

0 commit comments

Comments
 (0)