|
1 | 1 | package users
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "regexp" |
5 |
| - "std" |
6 | 4 | "strings"
|
7 | 5 |
|
| 6 | + "gno.land/p/demo/dao" |
8 | 7 | "gno.land/p/demo/releases"
|
9 |
| -) |
10 | 8 |
|
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" |
14 | 10 | )
|
15 | 11 |
|
| 12 | +var changelog = releases.NewChangelog("r/gnoland/users") |
| 13 | + |
| 14 | +const usersPrefix = "gno.land/r/gnoland/users/" |
| 15 | + |
16 | 16 | func init() {
|
17 | 17 | changelog.NewRelease("v1", "/r/gnoland/users/v1", "[Original PR](https://github.com/gnolang/gno/pull/3166)")
|
18 | 18 | }
|
19 | 19 |
|
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") |
25 | 28 | }
|
26 | 29 |
|
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 | + } |
30 | 35 |
|
31 |
| -func Render(_ string) string { |
32 |
| - return changelog.RenderAsTable(10) |
| 36 | + return bridge.GovDAO().NewGovDAOExecutor(cb) |
33 | 37 | }
|
0 commit comments