-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |