pull expand tool: add tea mode #153

Merged
jolheiser merged 3 commits from add-tea-mode-to-pulls into master 2021-03-13 15:10:58 +00:00
2 changed files with 18 additions and 3 deletions

@ -8,3 +8,5 @@ From the base directory
```
go run contrib/pulls/pulls.go --release 1.11.4
```
To convert tea release posts, switch to tea mode via `--tea` flag.

@ -9,13 +9,16 @@ import (
)
var (
pullURL = "https://github.com/go-gitea/gitea/pull/"
pullRegex = regexp.MustCompile(`#(\d+)\)`)
pullGiteaURL = "https://github.com/go-gitea/gitea/pull/"
pullTeaURL = "https://gitea.com/gitea/tea/pulls/"
noerw marked this conversation as resolved Outdated
Outdated
Review
- 	pullTeaURL   = "https://gitea.com/gitea/tea/pulls/"
+	pullTeaURL   = "https://gitea.com/gitea/tea/pull/"

?

```diff - pullTeaURL = "https://gitea.com/gitea/tea/pulls/" + pullTeaURL = "https://gitea.com/gitea/tea/pull/" ``` ?
Outdated
Review

@noerw you will get a 404 ...

test: https://gitea.com/gitea/tea/pull/313

@noerw you will get a 404 ... test: https://gitea.com/gitea/tea/pull/313
pullRegex = regexp.MustCompile(`#(\d+)\)`)
)
func main() {
var release string
var tea bool
flag.StringVar(&release, "release", "", "The release to target")
flag.BoolVar(&tea, "tea", false, "switch to tea mode")
flag.Parse()
if release == "" {
@ -23,7 +26,12 @@ func main() {
return
}
fi, err := os.OpenFile(fmt.Sprintf("content/post/release-of-%s.md", release), os.O_RDWR, os.ModePerm)
post := fmt.Sprintf("content/post/release-of-%s.md", release)
if tea {
post = fmt.Sprintf("content/post/release-of-tea-%s.md", release)
}
fi, err := os.OpenFile(post, os.O_RDWR, os.ModePerm)
if os.IsNotExist(err) {
fmt.Printf("could not find content/post/release-of-%s.md\n", release)
return
@ -39,6 +47,11 @@ func main() {
return
}
pullURL := pullGiteaURL
if tea {
pullURL = pullTeaURL
}
repl := pullRegex.ReplaceAll(data, []byte(`[#$1](`+pullURL+`$1))`))
if _, err := fi.WriteAt(repl, 0); err != nil {
fmt.Println(err)